@@ -125,7 +125,9 @@ def update_single_repository(pool_args):
125
125
return
126
126
127
127
try :
128
- print ("Updating '" + repo_path + "'" )
128
+ prefix = "[{0}] " .format (os .path .basename (repo_path )).ljust (40 )
129
+ print (prefix + "Updating '" + repo_path + "'" )
130
+
129
131
with shell .pushd (repo_path , dry_run = False , echo = False ):
130
132
cross_repo = False
131
133
checkout_target = None
@@ -141,15 +143,20 @@ def update_single_repository(pool_args):
141
143
142
144
# The clean option restores a repository to pristine condition.
143
145
if should_clean :
144
- shell .run (['git' , 'clean' , '-fdx' ], echo = True )
145
- shell .run (['git' , 'submodule' , 'foreach' , '--recursive' , 'git' ,
146
- 'clean' , '-fdx' ], echo = True )
147
- shell .run (['git' , 'submodule' , 'foreach' , '--recursive' , 'git' ,
148
- 'reset' , '--hard' , 'HEAD' ], echo = True )
149
- shell .run (['git' , 'reset' , '--hard' , 'HEAD' ], echo = True )
146
+ shell .run (['git' , 'clean' , '-fdx' ],
147
+ echo = True , prefix = prefix )
148
+ shell .run (['git' , 'submodule' , 'foreach' , '--recursive' ,
149
+ 'git' , 'clean' , '-fdx' ],
150
+ echo = True , prefix = prefix )
151
+ shell .run (['git' , 'submodule' , 'foreach' , '--recursive' ,
152
+ 'git' , 'reset' , '--hard' , 'HEAD' ],
153
+ echo = True , prefix = prefix )
154
+ shell .run (['git' , 'reset' , '--hard' , 'HEAD' ],
155
+ echo = True , prefix = prefix )
150
156
# It is possible to reset --hard and still be mid-rebase.
151
157
try :
152
- shell .run (['git' , 'rebase' , '--abort' ], echo = True )
158
+ shell .run (['git' , 'rebase' , '--abort' ],
159
+ echo = True , prefix = prefix )
153
160
except Exception :
154
161
pass
155
162
@@ -166,29 +173,32 @@ def update_single_repository(pool_args):
166
173
except Exception :
167
174
shell .run (["git" , "fetch" , "--recurse-submodules=yes" ,
168
175
"--tags" ],
169
- echo = True )
176
+ echo = True , prefix = prefix )
170
177
171
178
try :
172
- shell .run (['git' , 'checkout' , checkout_target ], echo = True )
179
+ shell .run (['git' , 'checkout' , checkout_target ],
180
+ echo = True , prefix = prefix )
173
181
except Exception as originalException :
174
182
try :
175
183
result = shell .run (['git' , 'rev-parse' , checkout_target ])
176
184
revision = result [0 ].strip ()
177
- shell .run (['git' , 'checkout' , revision ], echo = True )
185
+ shell .run (['git' , 'checkout' , revision ],
186
+ echo = True , prefix = prefix )
178
187
except Exception :
179
188
raise originalException
180
189
181
190
# It's important that we checkout, fetch, and rebase, in order.
182
191
# .git/FETCH_HEAD updates the not-for-merge attributes based on
183
192
# which branch was checked out during the fetch.
184
193
shell .run (["git" , "fetch" , "--recurse-submodules=yes" , "--tags" ],
185
- echo = True )
194
+ echo = True , prefix = prefix )
186
195
187
196
# If we were asked to reset to the specified branch, do the hard
188
197
# reset and return.
189
198
if checkout_target and reset_to_remote and not cross_repo :
190
199
full_target = full_target_name ('origin' , checkout_target )
191
- shell .run (['git' , 'reset' , '--hard' , full_target ], echo = True )
200
+ shell .run (['git' , 'reset' , '--hard' , full_target ],
201
+ echo = True , prefix = prefix )
192
202
return
193
203
194
204
# Query whether we have a "detached HEAD", which will mean that
@@ -215,13 +225,15 @@ def update_single_repository(pool_args):
215
225
# --rebase" that respects rebase.autostash. See
216
226
# http://stackoverflow.com/a/30209750/125349
217
227
if not cross_repo and not detached_head :
218
- shell .run (["git" , "rebase" , "FETCH_HEAD" ], echo = True )
228
+ shell .run (["git" , "rebase" , "FETCH_HEAD" ],
229
+ echo = True , prefix = prefix )
219
230
elif detached_head :
220
- print (repo_path ,
221
- "\n Detached HEAD; probably checked out a tag. No need "
222
- "to rebase.\n " )
231
+ print (prefix +
232
+ "Detached HEAD; probably checked out a tag. No need "
233
+ "to rebase." )
223
234
224
- shell .run (["git" , "submodule" , "update" , "--recursive" ], echo = True )
235
+ shell .run (["git" , "submodule" , "update" , "--recursive" ],
236
+ echo = True , prefix = prefix )
225
237
except Exception :
226
238
(type , value , tb ) = sys .exc_info ()
227
239
print ('Error on repo "%s": %s' % (repo_path , traceback .format_exc ()))
@@ -431,12 +443,12 @@ def validate_config(config):
431
443
432
444
433
445
def full_target_name (repository , target ):
434
- tag = shell .capture (["git" , "tag" , "-l" , target ], echo = True ).strip ()
446
+ tag = shell .capture (["git" , "tag" , "-l" , target ], echo = False ).strip ()
435
447
if tag == target :
436
448
return tag
437
449
438
450
branch = shell .capture (["git" , "branch" , "--list" , target ],
439
- echo = True ).strip ().replace ("* " , "" )
451
+ echo = False ).strip ().replace ("* " , "" )
440
452
if branch == target :
441
453
name = "%s/%s" % (repository , target )
442
454
return name
0 commit comments