Skip to content

Commit bae6ed3

Browse files
shr-projectSusan Montooth
authored andcommitted
mcf: Don't unnecessary call git remote update (v4.0.8)
:Release Notes: Don't call "git remote update" in every layer everytime someone calls mcf --command update, it's unnecessary fetching upstream layers which are updated every day, but all we're using from them is couple months old revision. :Detailed Notes: :Testing Performed: Only build tested. :QA Notes: No change to image. :Issues Addressed: [ES-515] mcf: Fix problem with local repository is out-of-sync with remote Open-webOS-DCO-1.0-Signed-off-by: Martin Jansa <martin.jansa@lge.com> Change-Id: Ie2cc68d71251bec59ad45675aadc46b346e49962 Reviewed-on: https://g2g.palm.com/5446 Reviewed-by: DCO Verification Build: Martin Jansa <Martin.Jansa@lge.com> Reviewed-by: Martin Jansa <Martin.Jansa@lge.com> Tested-by: Martin Jansa <Martin.Jansa@lge.com> Reviewed-by: Build Verification Reviewed-by: Susan Montooth <susan.montooth@lge.com>
1 parent 298d95b commit bae6ed3

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

‎mcf‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ from time import gmtime, strftime
2525
import shutil
2626
import glob
2727

28-
__version__ = "4.0.7"
28+
__version__ = "4.0.8"
2929

3030
logger = logging.getLogger(__name__)
3131

@@ -519,13 +519,25 @@ def printupdatesummary ():
519519
if BRANCHINFONEW[layer] != BRANCHINFOCURRENT[layer]:
520520
logger.info(' *) switched branches from %s to %s' % (BRANCHINFOCURRENT[layer], BRANCHINFONEW[layer]))
521521

522+
def get_remote_branch(newbranch, second_call = False):
523+
remotebranch = None
524+
refbranchlist = echo_check_call("git branch -r")
525+
refbranch = refbranchlist.splitlines()
526+
for ibranch in refbranch:
527+
if ibranch == " %s/%s" % (REMOTE, newbranch):
528+
remotebranch = ibranch.strip()
529+
break
530+
if remotebranch or second_call:
531+
return remotebranch
532+
else:
533+
# try it again after "git remote update"
534+
echo_check_call("git remote update")
535+
return get_remote_branch(newbranch, True)
536+
522537
def reposanitycheck(layer):
523538
olddir = os.getcwd()
524539
os.chdir(LOCATIONS[layer])
525540

526-
# Sync with remote repo
527-
echo_check_call('git remote update')
528-
529541
BRANCHINFOCURRENT[layer] = echo_check_call("git rev-parse --abbrev-ref HEAD").rstrip()
530542

531543
res = False
@@ -601,16 +613,9 @@ def reposanitycheck(layer):
601613
needcheckout = False
602614
break
603615

604-
refbranchlist = echo_check_call("git branch -r")
605-
refbranch = refbranchlist.splitlines()
606-
foundremotebranch = False
607-
for ibranch in refbranch:
608-
if ibranch == " %s/%s" % (REMOTE, newbranch):
609-
foundremotebranch = True
610-
remotebranch = ibranch.strip()
611-
break
616+
remotebranch = get_remote_branch(newbranch)
612617

613-
if foundlocalbranch and foundremotebranch:
618+
if foundlocalbranch and remotebranch:
614619
if needcheckout:
615620
echo_check_call('git checkout %s' % newbranch)
616621

@@ -651,7 +656,7 @@ def reposanitycheck(layer):
651656
# to ensure we are tracking remote
652657
echo_check_call('git branch --set-upstream %s %s' % (newbranch, remotebranch))
653658

654-
elif not foundlocalbranch and foundremotebranch:
659+
elif not foundlocalbranch and remotebranch:
655660
echo_check_call('git checkout -b %s %s' % (newbranch, remotebranch))
656661
else:
657662
# anything else is failure
@@ -715,6 +720,7 @@ def updaterepo(layer):
715720
echo_check_call(cmd)
716721
else:
717722
if CLEAN:
723+
echo_check_call("git remote update")
718724
echo_check_call('git reset --hard %s/%s' % (REMOTE, newbranch))
719725
else:
720726
# current branch always tracks a remote one

0 commit comments

Comments
 (0)