From 070381bb456b25f3e867e9b23b78911190c6b369 Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Sun, 11 Nov 2007 11:32:57 -0800 Subject: added remove and reset --- lib/git/base.rb | 13 +++++++++++++ lib/git/lib.rb | 18 ++++++++++++++++++ lib/git/status.rb | 4 ++++ 3 files changed, 35 insertions(+) (limited to 'lib') 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 } -- cgit