Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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