From: Robert Yang Date: Mon, 9 Jul 2018 03:28:38 +0000 (+0800) Subject: update.py: check whether branch existed when nocheckout X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Frbt%2Fli_recs;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git update.py: check whether branch existed when nocheckout Fixed: Assume there is no master branch in hello layer: $ update.py -l hello -b master INFO: Skipping update of layer hello - branch master doesn't exist This is correct since hello layer doesn't have master branch, but when --nocheckout: $ update.py -l hello -b master --nocheckout [snip] INFO: Sorting layers for branch mater: WARNING: Cannot find required collections on branch master: WARNING: hello: LAYERDEPENDS: This is incorrect, this patch fixed the problem, now it skips it since the branch doesn't exists when --nocheckout. Signed-off-by: Robert Yang --- diff --git a/layerindex/update.py b/layerindex/update.py index 5b5fc43d733..c0a9f88c9f1 100755 --- a/layerindex/update.py +++ b/layerindex/update.py @@ -345,10 +345,10 @@ def main(): repo = git.Repo(repodir) assert repo.bare == False try: + # Always get origin/branchname, so it raises error when branch doesn't exist when nocheckout + topcommit = repo.commit('origin/%s' % branchname) if options.nocheckout: topcommit = repo.commit('HEAD') - else: - topcommit = repo.commit('origin/%s' % branchname) except: if newbranch: logger.info("Skipping update of layer %s - branch %s doesn't exist" % (layer.name, branchdesc)) diff --git a/layerindex/update_layer.py b/layerindex/update_layer.py index 81b730a80a3..d941ae646f1 100644 --- a/layerindex/update_layer.py +++ b/layerindex/update_layer.py @@ -362,10 +362,9 @@ def main(): # Collect repo info repo = git.Repo(repodir) assert repo.bare == False + topcommit = repo.commit('origin/%s' % branchname) if options.nocheckout: topcommit = repo.commit('HEAD') - else: - topcommit = repo.commit('origin/%s' % branchname) tinfoil = None tempdir = None