File tree 3 files changed +39
-4
lines changed
3 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -604,10 +604,12 @@ def stashes_all
604
604
arr = [ ]
605
605
filename = File . join ( @git_dir , 'logs/refs/stash' )
606
606
if File . exist? ( filename )
607
- File . open ( filename ) . each_with_index { |line , i |
608
- m = line . match ( /:(.*)$/ )
609
- arr << [ i , m [ 1 ] . strip ]
610
- }
607
+ File . open ( filename ) do |f |
608
+ f . each_with_index do |line , i |
609
+ m = line . match ( /:(.*)$/ )
610
+ arr << [ i , m [ 1 ] . strip ]
611
+ end
612
+ end
611
613
end
612
614
arr
613
615
end
Original file line number Diff line number Diff line change @@ -13,6 +13,17 @@ def initialize(base)
13
13
@stashes . unshift ( Git ::Stash . new ( @base , message , true ) )
14
14
end
15
15
end
16
+
17
+ #
18
+ # Returns an multi-dimensional Array of elements that have been stash saved.
19
+ # Array is based on position and name. See Example
20
+ #
21
+ # @example Returns Array of items that have been stashed
22
+ # .all - [0, "testing-stash-all"]]
23
+ # @return [Array]
24
+ def all
25
+ @base . lib . stashes_all
26
+ end
16
27
17
28
def save ( message )
18
29
s = Git ::Stash . new ( @base , message )
Original file line number Diff line number Diff line change @@ -32,5 +32,27 @@ def test_stash_unstash
32
32
end
33
33
end
34
34
end
35
+
36
+ def test_stashes_all
37
+ in_temp_dir do |path |
38
+ g = Git . clone ( @wbare , 'stash_test' )
39
+ Dir . chdir ( 'stash_test' ) do
40
+ assert_equal ( 0 , g . branch . stashes . size )
41
+ new_file ( 'test-file1' , 'blahblahblah1' )
42
+ new_file ( 'test-file2' , 'blahblahblah2' )
43
+ assert ( g . status . untracked . assoc ( 'test-file1' ) )
44
+
45
+ g . add
46
+
47
+ assert ( g . status . added . assoc ( 'test-file1' ) )
48
+
49
+ g . branch . stashes . save ( 'testing-stash-all' )
50
+
51
+ stashes = g . branch . stashes . all
52
+
53
+ assert ( stashes [ 0 ] . include? ( 'testing-stash-all' ) )
54
+ end
55
+ end
56
+ end
35
57
36
58
end
You can’t perform that action at this time.
0 commit comments