Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@campbell
Created March 31, 2015 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save campbell/3a30c8f0f0edf0bbf732 to your computer and use it in GitHub Desktop.
Save campbell/3a30c8f0f0edf0bbf732 to your computer and use it in GitHub Desktop.
Automated GIT BISECT Bash function

Use this script to automatically find where a SPEC fail was introduced. You can add it to .bash_profile.

Syntax: run_git_bisect <bad SHA> <good SHA> <failing test file:number>

function run_git_bisect() {
  [ "$#" -eq 3 ] || die "You must provide the bad SHA, good SHA and the failing test filename[:number]"
  
  git bisect reset
  git bisect start
  echo "Marking commit $1 as bad"
  git bisect bad $1
  echo "Marking commit $2 as good"
  git bisect good $2
  git bisect run sh -c "bundle install & bundle exec rspec $3"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment