Method: Git::Base#grep
- Defined in:
- lib/git/base.rb
#grep(string, path_limiter = nil, opts = {}) ⇒ Object
will run a grep for ‘string’ on the HEAD of the git repository
to be more surgical in your grep, you can call grep() off a specific git object. for example:
@git.object("v2.3").grep('TODO')
in any case, it returns a hash of arrays of the type:
hsh[tree-ish] = [[line_no, match], [line_no, match2]]
hsh[tree-ish] = [[line_no, match], [line_no, match2]]
so you might use it like this:
@git.grep("TODO").each do |sha, arr|
puts "in blob #{sha}:"
arr.each do |match|
puts "\t line #{match[0]}: '#{match[1]}'"
end
end
206 207 208 |
# File 'lib/git/base.rb', line 206 def grep(string, path_limiter = nil, opts = {}) self.object('HEAD').grep(string, path_limiter, opts) end |