Fix imagebuilder to support `revision` attribute
A repo manifest can specify other branches on a project with the
`revision` attribute. Use this value rather than the default value when
a project specifies it, and checking for git cleanliness of a project.
Change-Id: I41473f1728d042fcdee18b64377b338066d70eaf
diff --git a/developer/imagebuilder.py b/developer/imagebuilder.py
index 8f619f1..e4848a6 100755
--- a/developer/imagebuilder.py
+++ b/developer/imagebuilder.py
@@ -231,6 +231,9 @@
self.git_repo_o = git.Repo(self.abspath())
LOG.debug("Repo - %s, path: %s" % (name, path))
+ LOG.debug(" local branch: %s" % self.short_branch)
+ LOG.debug(" remote branch: %s" % self.remote_branch)
+
self.head_commit = self.git_repo_o.head.commit.hexsha
LOG.debug(" head commit: %s" % self.head_commit)
@@ -271,7 +274,8 @@
if not branch:
branch = self.remote_branch
- LOG.debug(" Looking for changes in path: %s" % test_path)
+ LOG.debug(" Looking for differences from branch '%s' in path: %s" %
+ (branch, test_path))
p_clean = True
@@ -335,26 +339,31 @@
LOG.info("Manifest is on remote branch '%s' with remote url '%s'" %
(self.remote_branch, self.remote_url))
- project_repos = {}
-
for project in self.manifest_xml.iter('project'):
repo_name = project.attrib['name']
rel_path = project.attrib['path']
abs_path = os.path.abspath(os.path.join(args.repo_root,
project.attrib['path']))
+ if 'revision' in project.attrib:
+ p_short_branch = project.attrib['revision']
+ p_remote_branch = "%s/%s" % (default.attrib['remote'],
+ p_short_branch)
+ LOG.info('revision for project %s overridden with %s' %
+ (repo_name, p_short_branch))
+ else:
+ p_short_branch = self.short_branch
+ p_remote_branch = self.remote_branch
+
if os.path.isdir(abs_path):
- project_repos[repo_name] = rel_path
+ self.repos[repo_name] = RepoRepo(repo_name, rel_path,
+ self.remote_url,
+ p_remote_branch,
+ p_short_branch)
else:
LOG.debug("Repo in manifest but not checked out: %s" %
repo_name)
- for repo_name, repo_path in project_repos.iteritems():
- self.repos[repo_name] = RepoRepo(repo_name, repo_path,
- self.remote_url,
- self.remote_branch,
- self.short_branch)
-
def get_repo(self, repo_name):
return self.repos[repo_name]
@@ -1011,7 +1020,6 @@
parent = self.find_image(parent_name)
-
if parent is not None:
LOG.debug(" internal image '%s' is parent of '%s'" %
(parent.name, image.name))