Skip to content

Instantly share code, notes, and snippets.

@jamesdabbs
Created October 16, 2013 16:27
Show Gist options
  • Save jamesdabbs/7010720 to your computer and use it in GitHub Desktop.
Save jamesdabbs/7010720 to your computer and use it in GitHub Desktop.
A simple amalgam of git grep and git blame, mostly intended for finding FIXMEs that I introduced (as evidenced by the defaults) before merging them in.
#!/usr/bin/env ruby
word = ARGV.shift || "FIXME|TODO"
name = ARGV.shift || "James"
lines = `git grep -n -E '#{word}'`
lines.scan /(.*):(\d+)/ do |file, line|
up, down = line.to_i - 2, line.to_i + 5
blame = `git blame -w -L#{up},#{down} #{file}`
if blame =~ /#{name}.*(#{word})/
puts "-- #{file} ----->"
puts blame
puts
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment