Sha256: 040674ddc1e15054034767519c5359f534f2439a421b5a558552f0230103f63a

Contents?: true

Size: 1.06 KB

Versions: 46

Compression:

Stored size: 1.06 KB

Contents

module Git
  
  # object that holds all the available stashes
  class Stashes
    include Enumerable
    
    def initialize(base)
      @stashes = []
      
      @base = base
            
      @base.lib.stashes_all.each do |id, message|
        @stashes.unshift(Git::Stash.new(@base, message, true))
      end
    end

    #
    # Returns an multi-dimensional Array of elements that have been stash saved.
    # Array is based on position and name. See Example
    #
    # @example Returns Array of items that have been stashed
    #     .all - [0, "testing-stash-all"]]
    # @return [Array]
    def all
      @base.lib.stashes_all
    end
    
    def save(message)
      s = Git::Stash.new(@base, message)
      @stashes.unshift(s) if s.saved?
    end
    
    def apply(index=nil)
      @base.lib.stash_apply(index)
    end
    
    def clear
      @base.lib.stash_clear
      @stashes = []
    end

    def size
      @stashes.size
    end
    
    def each(&block)
      @stashes.each(&block)
    end
    
    def [](index)
      @stashes[index.to_i]
    end
    
  end
end

Version data entries

46 entries across 46 versions & 7 rubygems

Version Path
git-1.13.1 lib/git/stashes.rb
git-1.13.0 lib/git/stashes.rb
lg_pod_plugin-1.0.8 lib/git/stashes.rb
lg_pod_plugin-1.0.7 lib/git/stashes.rb
lg_pod_plugin-1.0.6 lib/git/stashes.rb
git-1.12.0 lib/git/stashes.rb
git-1.11.0 lib/git/stashes.rb
git-1.10.2 lib/git/stashes.rb
git-1.10.1 lib/git/stashes.rb
git-1.10.0 lib/git/stashes.rb
git-1.9.1 lib/git/stashes.rb
git-1.9.0 lib/git/stashes.rb
p-mongo-git-1.8.1 lib/git/stashes.rb
git-1.8.1 lib/git/stashes.rb
git-1.8.0 lib/git/stashes.rb
git-glimmer-1.7.0 lib/git/stashes.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/git-1.7.0/lib/git/stashes.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/git-1.7.0/lib/git/stashes.rb
git-1.7.0 lib/git/stashes.rb
git-1.6.0 lib/git/stashes.rb