Skip to content

Instantly share code, notes, and snippets.

@dvdasari
Last active August 29, 2015 14:06
Show Gist options
  • Save dvdasari/ac6369d8653a2a7b3eca to your computer and use it in GitHub Desktop.
Save dvdasari/ac6369d8653a2a7b3eca to your computer and use it in GitHub Desktop.
# ruby gitsearch.rb
search_term = "elasticsearch"
file_types = "*.rb"
`echo "\n############################" >> search_results.txt`
`echo "Search Term: #{search_term}" >> search_results.txt`
`echo "File Types: #{file_types}" >> search_results.txt`
`echo "############################\n" >> search_results.txt`
git_branches = `git branch`.split
git_branches.delete('*')
git_branches.each_with_index do |branch_name, ind|
puts "\n#{ind + 1 } branch_name: #{branch_name}"
print `git grep -e #{search_term} #{branch_name} -- '#{file_types}'`
`git grep -e #{search_term} #{branch_name} -- '#{file_types}' >> search_results.txt`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment