Skip to content

Instantly share code, notes, and snippets.

@grosser
Created January 11, 2012 22:54
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 grosser/1597288 to your computer and use it in GitHub Desktop.
Save grosser/1597288 to your computer and use it in GitHub Desktop.
git autobisect because bisect is too complicated....
@command = ARGV.join(' ')
if system @command
raise "Everything is fine here..."
end
def sh(cmd)
puts cmd
IO.popen(cmd) do |pipe|
while str = pipe.gets
puts str
end
end
$?.success?
end
def find_any_good_commit
commits = `git log --oneline | head -n 100`.split("\n").map{|c|c.split(' ').first}
current = 1
loop do
commit = commits[current]
sh "git checkout #{commit}"
if system @command
puts "everything ok at #{commit}"
return commit
else
puts "#{commit} is bad"
end
current = current * 2
end
end
good = find_any_good_commit
sh "git co master"
sh "git bisect reset"
sh "git bisect start"
sh "git bisect bad"
sh "git co #{good}"
sh "git bisect good"
exec "git bisect run #{@command}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment