From 55a5e323d241cfbd5a59d9a440c506b24b4c255a Mon Sep 17 00:00:00 2001 From: Eric Goodwin Date: Mon, 3 Mar 2008 10:49:28 -0800 Subject: Added in the stashes --- lib/git/stashes.rb | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 lib/git/stashes.rb (limited to 'lib/git/stashes.rb') diff --git a/lib/git/stashes.rb b/lib/git/stashes.rb new file mode 100644 index 0000000..78b1d59 --- /dev/null +++ b/lib/git/stashes.rb @@ -0,0 +1,49 @@ +module Git + + # object that holds all the available stashes + class Stashes + include Enumerable + + @base = nil + @stashes = nil + + def initialize(base) + @stashes = [] + + @base = base + + @base.lib.stashes_all.each do |id, message| + @stashes.unshift(Git::Stash.new(@base, message, true)) + end + end + + def save(message) + s = Git::Stash.new(@base, message) + @stashes.unshift(s) if s.saved? + end + + def apply(index=0) + @base.lib.stash_apply(index.to_i) + end + + def clear + @base.lib.stash_clear + @stashes = [] + end + + def size + @stashes.size + end + + def each + @stashes.each do |s| + yield s + end + end + + def [](symbol) + @stashes[symbol.to_s] + end + + end +end \ No newline at end of file -- cgit