1
1
from mock import patch
2
- from nose .plugins .attrib import attr
3
2
4
3
from gitsweep .tests .testcases import CommandTestCase
5
4
@@ -17,9 +16,9 @@ def test_help(self):
17
16
(retcode , stdout , stderr ) = self .gscommand ('git-sweep -h' )
18
17
19
18
self .assertResults ('''
20
- usage: git-sweep [-h] {preview,cleanup} ...
19
+ usage: git-sweep <action> [-h]
21
20
22
- Clean up your Git repository remote branches
21
+ Clean up your Git remote branches.
23
22
24
23
optional arguments:
25
24
-h, --help show this help message and exit
@@ -80,6 +79,35 @@ def test_will_preview(self):
80
79
To delete them, run again with `git-sweep cleanup`
81
80
''' , stdout )
82
81
82
+ def test_will_preserve_arguments (self ):
83
+ """
84
+ The recommended cleanup command contains the same arguments given.
85
+ """
86
+ for i in range (1 , 6 ):
87
+ self .command ('git checkout -b branch{0}' .format (i ))
88
+ self .make_commit ()
89
+ self .command ('git checkout master' )
90
+ self .make_commit ()
91
+ self .command ('git merge branch{0}' .format (i ))
92
+
93
+ preview = 'git-sweep preview --master=master --origin=origin'
94
+ cleanup = 'git-sweep cleanup --master=master --origin=origin'
95
+
96
+ (retcode , stdout , stderr ) = self .gscommand (preview )
97
+
98
+ self .assertResults ('''
99
+ Fetching from the remote
100
+ These branches have been merged into master:
101
+
102
+ branch1
103
+ branch2
104
+ branch3
105
+ branch4
106
+ branch5
107
+
108
+ To delete them, run again with `{0}`
109
+ ''' .format (cleanup ), stdout )
110
+
83
111
def test_will_preview_none_found (self ):
84
112
"""
85
113
Will preview the proposed deletes.
@@ -131,7 +159,7 @@ def test_will_cleanup(self):
131
159
All done!
132
160
133
161
Tell everyone to run `git fetch --prune` to sync with this remote.
134
- (you don't have to, your's is synced)
162
+ (you don't have to, yours is synced)
135
163
''' , stdout )
136
164
137
165
def test_will_abort_cleanup (self ):
@@ -163,7 +191,6 @@ def test_will_abort_cleanup(self):
163
191
OK, aborting.
164
192
''' , stdout )
165
193
166
- @attr ('focus' )
167
194
def test_will_skip_certain_branches (self ):
168
195
"""
169
196
Can be forced to skip certain branches.
@@ -178,6 +205,8 @@ def test_will_skip_certain_branches(self):
178
205
(retcode , stdout , stderr ) = self .gscommand (
179
206
'git-sweep preview --skip=branch1,branch2' )
180
207
208
+ cleanup = 'git-sweep cleanup --skip=branch1,branch2'
209
+
181
210
self .assertResults ('''
182
211
Fetching from the remote
183
212
These branches have been merged into master:
@@ -186,5 +215,40 @@ def test_will_skip_certain_branches(self):
186
215
branch4
187
216
branch5
188
217
189
- To delete them, run again with `git-sweep cleanup`
218
+ To delete them, run again with `{0}`
219
+ ''' .format (cleanup ), stdout )
220
+
221
+ def test_will_force_clean (self ):
222
+ """
223
+ Will cleanup immediately if forced.
224
+ """
225
+ for i in range (1 , 6 ):
226
+ self .command ('git checkout -b branch{0}' .format (i ))
227
+ self .make_commit ()
228
+ self .command ('git checkout master' )
229
+ self .make_commit ()
230
+ self .command ('git merge branch{0}' .format (i ))
231
+
232
+ (retcode , stdout , stderr ) = self .gscommand ('git-sweep cleanup --force' )
233
+
234
+ self .assertResults ('''
235
+ Fetching from the remote
236
+ These branches have been merged into master:
237
+
238
+ branch1
239
+ branch2
240
+ branch3
241
+ branch4
242
+ branch5
243
+
244
+ deleting branch1 (done)
245
+ deleting branch2 (done)
246
+ deleting branch3 (done)
247
+ deleting branch4 (done)
248
+ deleting branch5 (done)
249
+
250
+ All done!
251
+
252
+ Tell everyone to run `git fetch --prune` to sync with this remote.
253
+ (you don't have to, yours is synced)
190
254
''' , stdout )
0 commit comments