Use git bisect run to automatically find the first bad commit
git bisectto find the first bad commit.
In this talk, Sam showed us how he debugged a rspec issue using
But he is just manually using
git bisect good and
git bisect bad
to mark a commit as good/bad.
git bisect can run the script automatically:
git bisect start
git bisect good HEAD~4(for example)
git bisect bad HEAD
git bisect run rspec spec/services/some_spec.rb
git bisect will automatically run the script and find the first
commit from which this spec started to fail.
But in this talk's case, we need to run the script in another git directory. We can use shell script to switch to that directory first and then run the test suite:
git bisect run sh -c 'cd another/project/; rspec spec/in/that/project'
Of course, there are more complicated issues in real life projects,
gem dependency issue in the talk. We can always fallback to
manually tagging a commit as good/bad if we find something unexpected
from the log of
git bisect run.
You can also read more about
rspec bisect in my
previous post: RSpec failures caused by I18n.locale - dsdshome