@@ -443,6 +443,10 @@ def remove(file):
443
443
def commit ():
444
444
popen ([git_cmd , 'commit' , '-a' ] + (['-v' ] if verbose else ['-q' ]))
445
445
446
+ def merge (repo , dest ):
447
+ log ("Merging \" %s\" with \" %s\" from \" %s\" " % (repo .name , dest , repo .url ))
448
+ popen ([git_cmd , 'merge' , dest ] + (['-v' ] if verbose else ['-q' ]))
449
+
446
450
def publish (repo , all = None ):
447
451
if all :
448
452
popen ([git_cmd , 'push' , '--all' ] + (['-v' ] if verbose else ['-q' ]))
@@ -475,8 +479,9 @@ def checkout(repo, hash, clean=False):
475
479
if Git .isdetached (): # try to find associated refs to avoid detached state
476
480
refs = Git .getrefs (hash )
477
481
for ref in refs : # re-associate with a local or remote branch (hash is the same)
478
- log ("Hash \" %s\" match a branch reference. Re-associating with branch (it's the same hash)" % hash )
479
- popen ([git_cmd , 'checkout' , re .sub (r'^(.*?)\/(.*?)$' , r'\2' , ref )] + ([] if verbose else ['-q' ]))
482
+ branch = re .sub (r'^(.*?)\/(.*?)$' , r'\2' , ref )
483
+ log ("Hash \" %s\" matches a branch \" %s\" reference. Re-associating with branch" % (hash , branch ))
484
+ popen ([git_cmd , 'checkout' , branch ] + ([] if verbose else ['-q' ]))
480
485
break
481
486
482
487
def update (repo , hash = None , clean = False ):
@@ -490,8 +495,7 @@ def update(repo, hash=None, clean=False):
490
495
remote = Git .getremote ()
491
496
branch = Git .getbranch ()
492
497
if remote and branch :
493
- log ("Merging \" %s\" with remote branch %s/%s from \" %s\" " % (repo .name , remote , branch , repo .url ))
494
- popen ([git_cmd , 'merge' , "%s/%s" % (remote , branch )] + (['-v' ] if verbose else ['-q' ]))
498
+ Git .merge (repo , '%s/%s' % (remote , branch ))
495
499
else :
496
500
err = "Unable to update \" %s\" in \" %s\" .\n " % (repo .name , repo .path )
497
501
if not remote :
0 commit comments