@@ -44,4 +44,107 @@ def test_stashes_all
44
44
assert ( stashes [ 0 ] . include? ( 'testing-stash-all' ) )
45
45
end
46
46
end
47
+ test 'Git::Lib#stashes_all' do
48
+ in_bare_repo_clone do |g |
49
+ assert_equal ( 0 , g . branch . stashes . size )
50
+ new_file ( 'test-file1' , 'blahblahblah1' )
51
+ new_file ( 'test-file2' , 'blahblahblah2' )
52
+ assert ( g . status . untracked . assoc ( 'test-file1' ) )
53
+
54
+ g . add
55
+
56
+ assert ( g . status . added . assoc ( 'test-file1' ) )
57
+
58
+ g . branch . stashes . save ( 'testing-stash-all' )
59
+
60
+ # puts `cat .git/logs/refs/stash`
61
+ # 0000000000000000000000000000000000000000 b9b008cd179b0e8c4b8cda35bac43f7011a0836a James Couball <jcouball@yahoo.com> 1729463252 -0700 On master: testing-stash-all
62
+
63
+ stashes = assert_nothing_raised { g . lib . stashes_all }
64
+
65
+ expected_stashes = [
66
+ [ 0 , 'testing-stash-all' ]
67
+ ]
68
+
69
+ assert_equal ( expected_stashes , stashes )
70
+ end
71
+ end
72
+
73
+ test 'Git::Lib#stashes_all - stash message has colon' do
74
+ in_bare_repo_clone do |g |
75
+ assert_equal ( 0 , g . branch . stashes . size )
76
+ new_file ( 'test-file1' , 'blahblahblah1' )
77
+ new_file ( 'test-file2' , 'blahblahblah2' )
78
+ assert ( g . status . untracked . assoc ( 'test-file1' ) )
79
+
80
+ g . add
81
+
82
+ assert ( g . status . added . assoc ( 'test-file1' ) )
83
+
84
+ g . branch . stashes . save ( 'saving: testing-stash-all' )
85
+
86
+ # puts `cat .git/logs/refs/stash`
87
+ # 0000000000000000000000000000000000000000 b9b008cd179b0e8c4b8cda35bac43f7011a0836a James Couball <jcouball@yahoo.com> 1729463252 -0700 On master: saving: testing-stash-all
88
+
89
+ stashes = assert_nothing_raised { g . lib . stashes_all }
90
+
91
+ expected_stashes = [
92
+ [ 0 , 'saving: testing-stash-all' ]
93
+ ]
94
+
95
+ assert_equal ( expected_stashes , stashes )
96
+ end
97
+ end
98
+
99
+ test 'Git::Lib#stashes_all -- git stash message with no branch and no colon' do
100
+ in_temp_dir do
101
+ `git init`
102
+ `echo "hello world" > file1.txt`
103
+ `git add file1.txt`
104
+ `git commit -m "First commit"`
105
+ `echo "update" > file1.txt`
106
+ commit = `git stash create "stash message"` . chomp
107
+ # Create a stash with this message: 'custom message'
108
+ `git stash store -m "custom message" #{ commit } `
109
+
110
+ # puts `cat .git/logs/refs/stash`
111
+ # 0000000000000000000000000000000000000000 0550a54ed781eda364ca3c22fcc46c37acae4bd6 James Couball <jcouball@yahoo.com> 1729460302 -0700 custom message
112
+
113
+ git = Git . open ( '.' )
114
+
115
+ stashes = assert_nothing_raised { git . lib . stashes_all }
116
+
117
+ expected_stashes = [
118
+ [ 0 , 'custom message' ]
119
+ ]
120
+
121
+ assert_equal ( expected_stashes , stashes )
122
+ end
123
+ end
124
+
125
+ test 'Git::Lib#stashes_all -- git stash message with no branch and explicit colon' do
126
+ in_temp_dir do
127
+ `git init`
128
+ `echo "hello world" > file1.txt`
129
+ `git add file1.txt`
130
+ `git commit -m "First commit"`
131
+ `echo "update" > file1.txt`
132
+ commit = `git stash create "stash message"` . chomp
133
+ # Create a stash with this message: 'custom message'
134
+ `git stash store -m "testing: custom message" #{ commit } `
135
+
136
+ # puts `cat .git/logs/refs/stash`
137
+ # 0000000000000000000000000000000000000000 eadd7858e53ea4fb8b1383d69cade1806d948867 James Couball <jcouball@yahoo.com> 1729462039 -0700 testing: custom message
138
+
139
+ git = Git . open ( '.' )
140
+
141
+ stashes = assert_nothing_raised { git . lib . stashes_all }
142
+
143
+ expected_stashes = [
144
+ [ 0 , 'custom message' ]
145
+ ]
146
+
147
+ assert_equal ( expected_stashes , stashes )
148
+ end
149
+ end
47
150
end
0 commit comments