Class | Git::Base |
In: |
lib/git/base.rb
|
Parent: | Object |
clones a git repository locally
repository - http://repo.or.cz/w/sinatra.git name - sinatra
options:
:repository :bare or :working_directory :index_file
changes current working directory for a block to the git working directory
example
@git.chdir do # write files @git.add @git.commit('message') end
commits all pending changes in the index file to the git repository, but automatically adds all modified files without having to explicitly calling @git.add() on them.
g.config(‘user.name’, ‘Scott Chacon’) # sets value g.config(‘user.email’, ‘email@email.com’) # sets value g.config(‘user.name’) # returns ‘Scott Chacon’ g.config # returns whole config hash
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
this is a convenience method for accessing the class that wraps all the actual ‘git’ forked system calls. At some point I hope to replace the Git::Lib class with one that uses native methods or libgit C bindings
returns a Git::Object of the appropriate type you can also call @git.gtree(‘tree’), but that‘s just for readability. If you call @git.gtree(‘HEAD’) it will still return a Git::Object::Commit object.
@git.object calls a factory method that will run a rev-parse on the objectish and determine the type of the object and return an appropriate object for that type