Log the SHA of the Git ref for source builds

When using named refs in source builds, e.g. "reference = master", one
can't easily tell from the build output what SHA master actually pointed
to at that point and time. Update the debug output to include this.

Closes-Bug: #1566316

Change-Id: I95c1cc316ab7332fa30fa43e207a5a5512b76708
This commit is contained in:
Paul Bourke 2016-04-05 12:03:47 +01:00
parent 5f6d4d10d4
commit cfd806aeff

View File

@ -194,9 +194,10 @@ class WorkerThread(threading.Thread):
LOG.debug("%s:Cloning from %s", image['name'],
source['source'])
git.Git().clone(source['source'], clone_dir)
LOG.debug("%s:Git checkout by reference %s",
image['name'], source['reference'])
git.Git(clone_dir).checkout(source['reference'])
reference_sha = git.Git(clone_dir).rev_parse('HEAD')
LOG.debug("%s:Git checkout by reference %s (%s)",
image['name'], source['reference'], reference_sha)
except Exception as e:
LOG.error("%s:Failed to get source from git", image['name'])
LOG.error("%s:Error:%s", image['name'], str(e))