diff options
author | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-11 11:32:57 -0800 |
---|---|---|
committer | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-11 11:32:57 -0800 |
commit | 070381bb456b25f3e867e9b23b78911190c6b369 (patch) | |
tree | 140a03e14e0601e941f3b5192f9a81d362565d6e /lib/git | |
parent | 440ec51cded64d49c5c2aae949401dd60e4b876d (diff) | |
download | third_party-ruby-git-070381bb456b25f3e867e9b23b78911190c6b369.tar.gz third_party-ruby-git-070381bb456b25f3e867e9b23b78911190c6b369.tar.xz third_party-ruby-git-070381bb456b25f3e867e9b23b78911190c6b369.zip |
added remove and reset
Diffstat (limited to 'lib/git')
-rw-r--r-- | lib/git/base.rb | 13 | ||||
-rw-r--r-- | lib/git/lib.rb | 18 | ||||
-rw-r--r-- | lib/git/status.rb | 4 |
3 files changed, 35 insertions, 0 deletions
diff --git a/lib/git/base.rb b/lib/git/base.rb index 9be9fec..46c75eb 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -141,6 +141,19 @@ module Git self.lib.add(path) end + def remove(path = '.', opts = {}) + self.lib.remove(path, opts) + end + + def reset(commitish = nil, opts = {}) + self.lib.reset(commitish, opts) + end + + def reset_hard(commitish = nil, opts = {}) + opts = {:hard => true}.merge(opts) + self.lib.reset(path, opts) + end + def commit(message, opts = {}) self.lib.commit(message, opts) end diff --git a/lib/git/lib.rb b/lib/git/lib.rb index d857253..bc40e0c 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -212,11 +212,29 @@ module Git command('add', path) end + def remove(path = '.', opts = {}) + path = path.join(' ') if path.is_a?(Array) + + arr_opts = ['-f'] # overrides the up-to-date check by default + arr_opts << ['-r'] if opts[:recursive] + arr_opts << path + + command('rm', arr_opts) + end + def commit(message, opts = {}) arr_opts = ["-m '#{message}'"] arr_opts << '-a' if opts[:add_all] command('commit', arr_opts) end + + def reset(commit, opts = {}) + arr_opts = [] + arr_opts << '--hard' if opts[:hard] + arr_opts << commit.to_s if commit + command('reset', arr_opts) + end + private diff --git a/lib/git/status.rb b/lib/git/status.rb index f738644..7dcd284 100644 --- a/lib/git/status.rb +++ b/lib/git/status.rb @@ -18,6 +18,10 @@ module Git def added @files.select { |k, f| f.type == 'A' } end + + def deleted + @files.select { |k, f| f.type == 'D' } + end def untracked @files.select { |k, f| f.untracked } |