diff --git a/README b/README index f202fa5e..2cb258df 100644 --- a/README +++ b/README @@ -173,7 +173,11 @@ And here are the operations that will need to write to your git repository. g.branch(name).in_branch(message) { # add files } # auto-commits g.merge('new_branch') g.merge('origin/remote_branch') +<<<<<<< HEAD g.merge(g.branch('master')) +======= + g.merge(b.branch('master')) +>>>>>>> Added show_files and list directory suport g.merge([branch1, branch2]) r = g.add_remote(name, uri) # Git::Remote diff --git a/lib/git/base.rb b/lib/git/base.rb index 5ad8906a..257eda93 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -244,8 +244,8 @@ def diff(objectish = 'HEAD', obj2 = nil) end # adds files from the working directory to the git repository - def add(path = '.') - self.lib.add(path) + def add(path = '.',opts = {}) + self.lib.add(path,opts) end # removes file(s) from the git repository @@ -292,6 +292,10 @@ def checkout_file(version, file) self.lib.checkout_file(version,file) end + def show_file(version,file) + self.lib.show_file(version,file) + end + # fetches changes from a remote branch - this does not modify the working directory, # it just gets the changes from the remote if there are any def fetch(remote = 'origin') @@ -473,7 +477,10 @@ def current_branch self.lib.branch_current end - + def clean + puts "cleaning" + self.lib.clean + end end end diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 52fb2e6c..8d4cd657 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -28,6 +28,10 @@ def initialize(base = nil, logger = nil) def init command('init') end + + def clean + command('clean -f') + end # tries to clone the given repo # @@ -103,7 +107,7 @@ def revparse(string) return File.read(rev).chomp if rev command('rev-parse', string) end - + def namerev(string) command('name-rev', string).split[1] end @@ -392,8 +396,10 @@ def global_config_set(name, value) command('config', ['--global', name, value], false) end - def add(path = '.') - arr_opts = ['--'] + def add(path = '.', opts={}) + arr_opts = [] + arr_opts << ['-A'] if opts[:add_remove] + arr_opts << ['--'] if path.is_a?(Array) arr_opts += path else @@ -486,8 +492,12 @@ def branch_delete(branch) def checkout(branch, opts = {}) arr_opts = [] arr_opts << '-f' if opts[:force] - arr_opts << '-b' << opts[:new_branch] if opts[:new_branch] - arr_opts << branch + if( opts[:force_branch] ) + arr_opts << '-B' << opts[:force_branch] + else + arr_opts << '-b' << opts[:new_branch] if opts[:new_branch] + end + arr_opts << branch if branch command('checkout', arr_opts) end @@ -498,6 +508,12 @@ def checkout_file(version, file) arr_opts << file command('checkout', arr_opts) end + + def show_file(version, file) + arr_opts = [] + arr_opts << "#{version}:#{file}" + command('show', arr_opts) + end def merge(branch, message = nil) arr_opts = []