Skip to content

Commit 4a69c8e

Browse files
shr-projectSusan Montooth
authored andcommitted
mcf: Remove update parameter from downloadrepo function (v4.0.9)
:Release Notes: downloadrepo function called with update parameter set to True just calls updaterepo, let the caller to call right function directly. :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: If7ebbb5d8b26aed0755bac93a50e63067edc4b3d Reviewed-on: https://g2g.palm.com/5447 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 bae6ed3 commit 4a69c8e

File tree

1 file changed

+54
-58
lines changed

1 file changed

+54
-58
lines changed

‎mcf‎

Lines changed: 54 additions & 58 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.8"
28+
__version__ = "4.0.9"
2929

3030
logger = logging.getLogger(__name__)
3131

@@ -330,75 +330,71 @@ def parsesubmissions(layer):
330330
COMMITIDSNEW[layer] = COMMIT
331331
TAGSINFONEW[layer] = TAG
332332

333-
def downloadrepo(layer,update=False):
334-
if not update:
335-
cmd = 'git clone %s %s' % (URLS[layer], LOCATIONS[layer])
336-
echo_check_call(cmd)
337-
338-
olddir = os.getcwd()
339-
os.chdir(LOCATIONS[layer])
333+
def downloadrepo(layer):
334+
cmd = 'git clone %s %s' % (URLS[layer], LOCATIONS[layer])
335+
echo_check_call(cmd)
340336

341-
newbranch = BRANCHINFONEW[layer]
337+
olddir = os.getcwd()
338+
os.chdir(LOCATIONS[layer])
339+
newbranch = BRANCHINFONEW[layer]
342340

343-
if newbranch:
344-
refbranchlist = echo_check_call("git branch")
341+
if newbranch:
342+
refbranchlist = echo_check_call("git branch")
343+
refbranch = refbranchlist.splitlines()
344+
foundbranch = False
345+
for ibranch in refbranch:
346+
if newbranch in ibranch:
347+
foundbranch = True
348+
if not foundbranch:
349+
refbranchlist = echo_check_call("git branch -r")
345350
refbranch = refbranchlist.splitlines()
346-
foundbranch = False
347351
for ibranch in refbranch:
348-
if newbranch in ibranch:
352+
if ibranch == " %s/%s" % (REMOTE, newbranch):
349353
foundbranch = True
350-
if not foundbranch:
351-
refbranchlist = echo_check_call("git branch -r")
352-
refbranch = refbranchlist.splitlines()
353-
for ibranch in refbranch:
354-
if ibranch == " %s/%s" % (REMOTE, newbranch):
355-
foundbranch = True
356-
logger.info( " found %s " % ibranch )
357-
cmd ='git checkout -B %s %s' % (newbranch,ibranch)
358-
echo_check_call(cmd)
359-
break
360-
361-
currentbranch = echo_check_call("git rev-parse --abbrev-ref HEAD").rstrip()
362-
newcommitid = COMMITIDSNEW[layer]
363-
if newcommitid:
364-
if newcommitid.startswith('refs/changes/'):
365-
if newbranch and newbranch != currentbranch:
366-
# older git doesn't allow to update reference on currently checked out branch
367-
cmd ='git fetch %s %s && git checkout -B %s FETCH_HEAD' % (REMOTE, newcommitid, newbranch)
368-
elif newbranch:
369-
# we're already on requested branch
370-
cmd ='git fetch %s %s && git reset --hard FETCH_HEAD' % (REMOTE, newcommitid)
371-
else:
372-
# we don't have any branch preference use detached
373-
cmd ='git fetch %s %s && git checkout FETCH_HEAD' % (REMOTE, newcommitid)
374-
echo_check_call(cmd)
375-
else:
376-
if newbranch and newbranch != currentbranch:
377-
# older git doesn't allow to update reference on currently checked out branch
378-
cmd ='git checkout -B %s %s' % (newbranch,newcommitid)
379-
elif newbranch:
380-
# we're already on requested branch
381-
cmd ='git reset --hard %s' % newcommitid
382-
else:
383-
# we don't have any branch preference use detached
384-
cmd ='git checkout %s' % newcommitid
385-
echo_check_call(cmd)
354+
logger.info( " found %s " % ibranch )
355+
cmd ='git checkout -B %s %s' % (newbranch,ibranch)
356+
echo_check_call(cmd)
357+
break
386358

387-
newtag = TAGSINFONEW[layer]
388-
if newtag:
359+
currentbranch = echo_check_call("git rev-parse --abbrev-ref HEAD").rstrip()
360+
newcommitid = COMMITIDSNEW[layer]
361+
if newcommitid:
362+
if newcommitid.startswith('refs/changes/'):
389363
if newbranch and newbranch != currentbranch:
390364
# older git doesn't allow to update reference on currently checked out branch
391-
cmd ='git checkout -B %s %s' % (newbranch,newtag)
365+
cmd ='git fetch %s %s && git checkout -B %s FETCH_HEAD' % (REMOTE, newcommitid, newbranch)
392366
elif newbranch:
393367
# we're already on requested branch
394-
cmd ='git reset --hard %s' % newtag
368+
cmd ='git fetch %s %s && git reset --hard FETCH_HEAD' % (REMOTE, newcommitid)
395369
else:
396-
cmd ='git checkout %s' % newtag
370+
# we don't have any branch preference use detached
371+
cmd ='git fetch %s %s && git checkout FETCH_HEAD' % (REMOTE, newcommitid)
372+
echo_check_call(cmd)
373+
else:
374+
if newbranch and newbranch != currentbranch:
375+
# older git doesn't allow to update reference on currently checked out branch
376+
cmd ='git checkout -B %s %s' % (newbranch,newcommitid)
377+
elif newbranch:
378+
# we're already on requested branch
379+
cmd ='git reset --hard %s' % newcommitid
380+
else:
381+
# we don't have any branch preference use detached
382+
cmd ='git checkout %s' % newcommitid
397383
echo_check_call(cmd)
398384

399-
os.chdir(olddir)
400-
else:
401-
updaterepo(layer)
385+
newtag = TAGSINFONEW[layer]
386+
if newtag:
387+
if newbranch and newbranch != currentbranch:
388+
# older git doesn't allow to update reference on currently checked out branch
389+
cmd ='git checkout -B %s %s' % (newbranch,newtag)
390+
elif newbranch:
391+
# we're already on requested branch
392+
cmd ='git reset --hard %s' % newtag
393+
else:
394+
cmd ='git checkout %s' % newtag
395+
echo_check_call(cmd)
396+
397+
os.chdir(olddir)
402398

403399
def parselayerconffile(layer, layerconffile):
404400
with open(layerconffile, 'r') as f:
@@ -499,7 +495,7 @@ def update_layers(sourcedir):
499495
# update layers
500496
for layer in WEBOSLAYERS:
501497
if layer in updated_layers:
502-
downloadrepo(layer,True)
498+
updaterepo(layer)
503499
printupdatesummary()
504500

505501
def printupdatesummary ():

0 commit comments

Comments
 (0)