Quantcast
Channel: Built from source.
Viewing all articles
Browse latest Browse all 21

Git bisect is the best thing ever

$
0
0

I’ve raved about this command to coworkers before, but this morning after a bundle install with edge Rails our multi-database migrations broke, and I needed to figure out why. This had happened sometime between November 15 and December 2… on a less active codebase that might not be a big deal, but there were 204 commits to Rails in that time.

Enter git bisect!

$ cd rails/
local:rails matt$ git bisect start
local:rails matt$ git bisect bad
local:rails matt$ git bisect good 8124b2bc24b8312ee4d1ce2f133bf6e2dd87ad49
Bisecting: 204 revisions left to test after this (roughly 8 steps)
[51007f1dbafe029ed85b2a296736a00e6b24ec58] Previous version inaccurately suggested that
local:rails matt$ git bisect bad
Bisecting: 101 revisions left to test after this (roughly 7 steps)
[77440ec51ad28a7e63651f0976053584a7f58768] fixing assertions so error messages will be more helpful
local:rails matt$ git bisect good
Bisecting: 50 revisions left to test after this (roughly 6 steps)
[96b50a039276b4391ddf07b0a74850ce7bad6863] IrreversibleMigration is raised if we cannot invert the command
local:rails matt$ git bisect bad
Bisecting: 25 revisions left to test after this (roughly 5 steps)
[56c5820458fd3981161393c285cce67fdf35e60b] use shorter form for sql literals
local:rails matt$ git bisect bad
Bisecting: 12 revisions left to test after this (roughly 4 steps)
[f14c2bf58204f488cbe589e077a124865ea595f5] Pass the view object as parameter to the handler. Useful if you need to access the lookup context or other information when compiling the template.
local:rails matt$ git bisect bad
Bisecting: 5 revisions left to test after this (roughly 3 steps)
[974ff0dd43826aa375417852356ceede1bd24cf2] singleton method added is no longer needed
local:rails matt$ git bisect bad
Bisecting: 2 revisions left to test after this (roughly 2 steps)
[fe2f168d40385a0412f41c1a2a44a5536cada8df] fix warning during test execution
local:rails matt$ git bisect good
Bisecting: 0 revisions left to test after this (roughly 1 step)
[0bea9fd6be1c82154d7b2d4adbfc690a2c1df297] schema migrations work as instances
local:rails matt$ git bisect bad
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[8b2f801ed8690dcbc61d62e6b3518efaac70a4a4] converted migrations to support instance methods
local:rails matt$ git bisect bad
8b2f801ed8690dcbc61d62e6b3518efaac70a4a4 is the first bad commit
commit 8b2f801ed8690dcbc61d62e6b3518efaac70a4a4
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Nov 17 12:53:38 2010 -0800

    converted migrations to support instance methods

:040000 040000 8e4adf421f6b9d8e6d696ac9526319b8e71bb486 cf3def12c0e5c1e92393f7293a5c5c9637d5af8f M  activerecord

If it’s a relatively simple bug to isolate, look into git bisect run–it makes the process entirely automated.

(Oh, and by the way, if anyone is running into the same problem I did, ActiveRecord::Base.connection is now ActiveRecord::Base#connection. In other words, it’s now an instance method, not a class method.)


Viewing all articles
Browse latest Browse all 21

Trending Articles