Skip to content

Instantly share code, notes, and snippets.

@radamant
Created February 15, 2012 17:39
Show Gist options
  • Save radamant/1837541 to your computer and use it in GitHub Desktop.
Save radamant/1837541 to your computer and use it in GitHub Desktop.
A feature branch git-grep script
#!/usr/bin/env ruby
require 'set'
@term = ARGV[0]
def set_from_command(command)
result = `#{command}`
Set.new(result.split "\n")
end
current_hits = set_from_command "git grep #{@term}"
master_hits = set_from_command "git grep #{@term} master | sed s/^master://"
puts "matches for '#{@term}' not in master:"
puts '-' * 80
puts (current_hits - master_hits).to_a
exit
sputnik:robut-rdio(omit-empty-tracks) $ ~/current_branch_grep stream
matches for 'stream' not in master:
--------------------------------------------------------------------------------
lib/actions/find_action.rb: # We also want to exclude the tracks that cannot be streamed from the resultset
lib/actions/find_action.rb: result.can_stream ? result : nil
sputnik:robut-rdio(omit-empty-tracks) $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment