aboutsummaryrefslogtreecommitdiffstats
path: root/layerindex
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2014-05-24 17:26:01 +0100
committerPaul Eggleton <paul.eggleton@linux.intel.com>2014-05-24 17:29:23 +0100
commit7c4a1c1dab154ffd67846c3f270374a1b1f5be3a (patch)
treebadb55d5e952d9e258e9bd5bf3914b4cd46eb23f /layerindex
parentf0b517796fd3c7cebfdd1be203c3cb13d0a44493 (diff)
downloadopenembedded-core-contrib-7c4a1c1dab154ffd67846c3f270374a1b1f5be3a.tar.gz
openembedded-core-contrib-7c4a1c1dab154ffd67846c3f270374a1b1f5be3a.tar.bz2
openembedded-core-contrib-7c4a1c1dab154ffd67846c3f270374a1b1f5be3a.zip
update.py: fix layer exists-on-branch check
There was a logic error here - we were checking to see if the layer directory existed before actually checking out the branch, which means we were looking at the state of whatever branch was previously checked out. Replace this with some validation of the last revision check and an additional check for the directory after checking out the branch. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'layerindex')
-rwxr-xr-xlayerindex/update.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/layerindex/update.py b/layerindex/update.py
index 5670d6272b..d194f86072 100755
--- a/layerindex/update.py
+++ b/layerindex/update.py
@@ -273,8 +273,10 @@ def main():
transaction.rollback()
continue
+ newbranch = False
if not layerbranch:
# LayerBranch doesn't exist for this branch, create it
+ newbranch = True
layerbranch = LayerBranch()
layerbranch.layer = layer
layerbranch.branch = branch
@@ -283,12 +285,6 @@ def main():
layerbranch_source = layer.get_layerbranch(None)
if layerbranch_source:
layerbranch.vcs_subdir = layerbranch_source.vcs_subdir
- if layerbranch.vcs_subdir:
- checksubdir = os.path.join(repodir, layerbranch.vcs_subdir)
- if not os.path.exists(checksubdir):
- logger.info("Skipping update of layer %s for branch %s - subdirectory %s does not exist on this branch" % (layer.name, branchdesc, layerbranch.vcs_subdir))
- transaction.rollback()
- continue
layerbranch.save()
if layerbranch_source:
for maintainer in layerbranch_source.layermaintainer_set.all():
@@ -305,9 +301,19 @@ def main():
if layerbranch.vcs_subdir and not options.nocheckout:
# Find latest commit in subdirectory
# A bit odd to do it this way but apparently there's no other way in the GitPython API
- for commit in repo.iter_commits('origin/%s' % branchname, paths=layerbranch.vcs_subdir):
- topcommit = commit
- break
+ topcommit = next(repo.iter_commits('origin/%s' % branchname, paths=layerbranch.vcs_subdir), None)
+ if not topcommit:
+ # This will error out if the directory is completely invalid or had never existed at this point
+ # If it previously existed but has since been deleted, you will get the revision where it was
+ # deleted - so we need to handle that case separately later
+ if newbranch:
+ logger.info("Skipping update of layer %s for branch %s - subdirectory %s does not exist on this branch" % (layer.name, branchdesc, layerbranch.vcs_subdir))
+ elif layerbranch.vcs_subdir:
+ logger.error("Subdirectory for layer %s does not exist on branch %s - if this is legitimate, the layer branch record should be deleted" % (layer.name, branchdesc))
+ else:
+ logger.error("Failed to get last revision for layer %s on branch %s" % (layer.name, branchdesc))
+ transaction.rollback()
+ continue
layerdir = os.path.join(repodir, layerbranch.vcs_subdir)
layerdir_start = os.path.normpath(layerdir) + os.sep
@@ -321,11 +327,13 @@ def main():
out = utils.runcmd("git checkout origin/%s" % branchname, repodir, logger=logger)
out = utils.runcmd("git clean -f -x", repodir, logger=logger)
- if not os.path.exists(layerdir):
- if options.branch == 'master':
+ if layerbranch.vcs_subdir and not os.path.exists(layerdir):
+ if newbranch:
+ logger.info("Skipping update of layer %s for branch %s - subdirectory %s does not exist on this branch" % (layer.name, branchdesc, layerbranch.vcs_subdir))
+ else:
logger.error("Subdirectory for layer %s does not exist on branch %s - if this is legitimate, the layer branch record should be deleted" % (layer.name, branchdesc))
- transaction.rollback()
- continue
+ transaction.rollback()
+ continue
if not os.path.exists(os.path.join(layerdir, 'conf/layer.conf')):
logger.error("conf/layer.conf not found for layer %s - is subdirectory set correctly?" % layer.name)