Class: Git::Stashes Deprecated
Overview
Use Repository#stash_infos and StashInfo instead
Collection of stash entries for a Git repository
This class is deprecated and will be removed in v6.0.0. Use the Repository stash methods and StashInfo instead: Repository#stash_infos replaces the collection, and Repository#stash_push, Repository#stash_apply, and Repository#stash_clear replace #save, #apply, and #clear.
Instance Method Summary collapse
-
#[](index) ⇒ Git::Stash?
Returns the stash entry at the given index.
-
#all ⇒ Array<Array(Integer, String)>
Returns all stash entries as an array of index and message pairs.
-
#apply(index = nil) ⇒ String
Applies a stash entry to the working directory.
-
#clear
Removes all stash entries.
-
#each
Iterates over each stash entry in newest-first order.
-
#initialize(base)
constructor
deprecated
Deprecated.
Use Repository#stash_infos and StashInfo instead
-
#save(message)
Saves the current working-directory state to a new stash entry.
-
#size ⇒ Integer
Returns the number of stash entries.
Constructor Details
#initialize(base)
Use Repository#stash_infos and Git::StashInfo instead
Initialize the stashes collection
Loads all existing stash entries from the repository at construction time. Emits one deprecation warning per object.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/git/stashes.rb', line 46 def initialize(base) Git::Deprecation.warn( 'Git::Stashes is deprecated and will be removed in v6.0.0. ' \ 'Use the Git::Repository stash methods (stash_infos, stash_push, stash_apply, stash_clear) ' \ 'and Git::StashInfo instead.' ) @stashes = [] @base = base # stashes_all and Git::Stash are deprecated too; silence them so one # Git::Stashes.new emits one warning Git::Deprecation.silence { load_stashes } end |
Instance Method Details
#[](index) ⇒ Git::Stash?
Returns the stash entry at the given index
Stashes are stored in newest-first order; index 0 is the most recent stash.
173 174 175 |
# File 'lib/git/stashes.rb', line 173 def [](index) @stashes[index.to_i] end |
#all ⇒ Array<Array(Integer, String)>
Returns all stash entries as an array of index and message pairs
Entries are listed in oldest-first order matching Repository#stashes_all.
71 72 73 74 |
# File 'lib/git/stashes.rb', line 71 def all # stashes_all is deprecated too; silence it so this call emits no second warning Git::Deprecation.silence { stash_repository.stashes_all } end |
#apply(index = nil) ⇒ String
Applies a stash entry to the working directory
108 109 110 |
# File 'lib/git/stashes.rb', line 108 def apply(index = nil) stash_repository.stash_apply(index) end |
#clear
This method returns an undefined value.
Removes all stash entries
122 123 124 125 126 |
# File 'lib/git/stashes.rb', line 122 def clear stash_repository.stash_clear @stashes = [] nil end |
#each ⇒ Enumerator<Git::Stash> #each {|stash| ... } ⇒ Array<Git::Stash>
Iterates over each stash entry in newest-first order
158 159 160 |
# File 'lib/git/stashes.rb', line 158 def each(&) @stashes.each(&) end |
#save(message)
This method returns an undefined value.
Saves the current working-directory state to a new stash entry
88 89 90 91 92 |
# File 'lib/git/stashes.rb', line 88 def save() # Git::Stash is deprecated too; silence it so this call emits no second warning s = Git::Deprecation.silence { Git::Stash.new(@base, ) } @stashes.unshift(s) if s.saved? end |
#size ⇒ Integer
Returns the number of stash entries
135 136 137 |
# File 'lib/git/stashes.rb', line 135 def size @stashes.size end |