@@ -125,7 +125,9 @@ def update_single_repository(pool_args):
125125 return
126126
127127 try :
128- print ("Updating '" + repo_path + "'" )
128+ prefix = "[{0}] " .format (os .path .basename (repo_path )).ljust (40 )
129+ print (prefix + "Updating '" + repo_path + "'" )
130+
129131 with shell .pushd (repo_path , dry_run = False , echo = False ):
130132 cross_repo = False
131133 checkout_target = None
@@ -141,15 +143,20 @@ def update_single_repository(pool_args):
141143
142144 # The clean option restores a repository to pristine condition.
143145 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 )
150156 # It is possible to reset --hard and still be mid-rebase.
151157 try :
152- shell .run (['git' , 'rebase' , '--abort' ], echo = True )
158+ shell .run (['git' , 'rebase' , '--abort' ],
159+ echo = True , prefix = prefix )
153160 except Exception :
154161 pass
155162
@@ -166,29 +173,32 @@ def update_single_repository(pool_args):
166173 except Exception :
167174 shell .run (["git" , "fetch" , "--recurse-submodules=yes" ,
168175 "--tags" ],
169- echo = True )
176+ echo = True , prefix = prefix )
170177
171178 try :
172- shell .run (['git' , 'checkout' , checkout_target ], echo = True )
179+ shell .run (['git' , 'checkout' , checkout_target ],
180+ echo = True , prefix = prefix )
173181 except Exception as originalException :
174182 try :
175183 result = shell .run (['git' , 'rev-parse' , checkout_target ])
176184 revision = result [0 ].strip ()
177- shell .run (['git' , 'checkout' , revision ], echo = True )
185+ shell .run (['git' , 'checkout' , revision ],
186+ echo = True , prefix = prefix )
178187 except Exception :
179188 raise originalException
180189
181190 # It's important that we checkout, fetch, and rebase, in order.
182191 # .git/FETCH_HEAD updates the not-for-merge attributes based on
183192 # which branch was checked out during the fetch.
184193 shell .run (["git" , "fetch" , "--recurse-submodules=yes" , "--tags" ],
185- echo = True )
194+ echo = True , prefix = prefix )
186195
187196 # If we were asked to reset to the specified branch, do the hard
188197 # reset and return.
189198 if checkout_target and reset_to_remote and not cross_repo :
190199 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 )
192202 return
193203
194204 # Query whether we have a "detached HEAD", which will mean that
@@ -215,13 +225,15 @@ def update_single_repository(pool_args):
215225 # --rebase" that respects rebase.autostash. See
216226 # http://stackoverflow.com/a/30209750/125349
217227 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 )
219230 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." )
223234
224- shell .run (["git" , "submodule" , "update" , "--recursive" ], echo = True )
235+ shell .run (["git" , "submodule" , "update" , "--recursive" ],
236+ echo = True , prefix = prefix )
225237 except Exception :
226238 (type , value , tb ) = sys .exc_info ()
227239 print ('Error on repo "%s": %s' % (repo_path , traceback .format_exc ()))
@@ -431,12 +443,12 @@ def validate_config(config):
431443
432444
433445def 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 ()
435447 if tag == target :
436448 return tag
437449
438450 branch = shell .capture (["git" , "branch" , "--list" , target ],
439- echo = True ).strip ().replace ("* " , "" )
451+ echo = False ).strip ().replace ("* " , "" )
440452 if branch == target :
441453 name = "%s/%s" % (repository , target )
442454 return name
0 commit comments