module Git
def self.bare(git_dir, options = {})
so you can't checkout stuff, commit things, etc.
it expects not to be able to use a working directory
this takes the path to a bare git repo
open a bare repository
def self.bare(git_dir, options = {}) Base.bare(git_dir, options) end
def self.clone(repository, name, options = {})
Git.clone('git://repo.or.cz/rubygit.git', 'clone.git', :bare => true)
example
:index => '/path/to/alt_index_file'
:repository => '/path/to/alt_git_dir'
:bare => true (does a bare clone)
options
clones a remote repository
def self.clone(repository, name, options = {}) Base.clone(repository, name, options) end
def self.config
def self.config return Base.config end
def self.configure
def self.configure yield Base.config end
def self.export(repository, name, options = {})
since the .git info will be deleted anyway; always uses the default
See +clone+ for options. Does not obey the :remote option,
directory.
is specified) into the +name+ directory, then remove all traces of git from the
Export the current HEAD (or a branch, if options[:branch]
def self.export(repository, name, options = {}) options.delete(:remote) repo = clone(repository, name, {:depth => 1}.merge(options)) repo.checkout("origin/#{options[:branch]}") if options[:branch] Dir.chdir(repo.dir.to_s) { FileUtils.rm_r '.git' } end
def self.global_config(name = nil, value = nil)
g.config('user.name') # returns 'Scott Chacon'
g.config('user.email', 'email@email.com') # sets value
g.config('user.name', 'Scott Chacon') # sets value
Same as g.config, but forces it to be at the global level
def self.global_config(name = nil, value = nil) lib = Git::Lib.new(nil, nil) if(name && value) # set value lib.global_config_set(name, value) elsif (name) # return value lib.global_config_get(name) else # return hash lib.global_config_list end end
def self.init(working_dir = '.', options = {})
:repository => '/path/to/alt_git_dir'
options
initialize a new git repository, defaults to the current working directory
def self.init(working_dir = '.', options = {}) Base.init(working_dir, options) end
def self.ls_remote(location=nil)
-
({String=>Hash})
- the available references of the target repo.
Parameters:
-
location
(String|NilClass
) -- the target repository location or nil for '.'
def self.ls_remote(location=nil) Git::Lib.new.ls_remote(location) end
def self.open(working_dir, options = {})
:repository => '/path/to/alt_git_dir'
options
your git_dir and index are in the default place (.git/, .git/index)
if not provided in the options, the library will assume
a git reference, referring to a working directory.
this will most likely be the most common way to create
open an existing git working directory
def self.open(working_dir, options = {}) Base.open(working_dir, options) end
def config(name = nil, value = nil)
g.config('user.name') # returns 'Scott Chacon'
g.config('user.email', 'email@email.com') # sets value
g.config('user.name', 'Scott Chacon') # sets value
def config(name = nil, value = nil) lib = Git::Lib.new if(name && value) # set value lib.config_set(name, value) elsif (name) # return value lib.config_get(name) else # return hash lib.config_list end end
def global_config(name = nil, value = nil)
def global_config(name = nil, value = nil) self.class.global_config(name, value) end