Add debug log statements so that SCM problems are easier to debug in the future

This commit is contained in:
mprahl
2019-04-29 14:24:16 -04:00
parent 1885a8b11f
commit 02f00d93c1
2 changed files with 17 additions and 6 deletions

View File

@@ -217,10 +217,11 @@ class SCM(object):
# fallbac to `get_full_commit_hash`. We do not want to retry here, because
# in case module contains only commit hashes, it would block for very long
# time.
_, output, _ = SCM._run_without_retry(
["git", "ls-remote", "--exit-code", self.repository, "refs/heads/" + ref]
)
cmd = ["git", "ls-remote", "--exit-code", self.repository, "refs/heads/" + ref]
log.debug("Checking to see if the ref %s is a branch with `%s`", ref, " ".join(cmd))
_, output, _ = SCM._run_without_retry(cmd)
except UnprocessableEntity:
log.debug("The ref %s is not a branch. Checking to see if it's a commit hash", ref)
# The call below will either return the commit hash as is (if a full one was
# provided) or the full commit hash (if a short hash was provided). If ref is not
# a commit hash, then this will raise an exception.
@@ -248,12 +249,19 @@ class SCM(object):
raise RuntimeError('No commit hash was specified for "{0}"'.format(self.url))
if self.scheme == "git":
log.debug('Getting the full commit hash for "{0}"'.format(self.repository))
log.debug(
"Getting the full commit hash on %s from %s", self.repository, commit_to_check)
td = None
try:
td = tempfile.mkdtemp()
SCM._run(["git", "clone", "-q", self.repository, td, "--bare"])
output = SCM._run(["git", "rev-parse", commit_to_check], chdir=td)[1]
cmd = ["git", "rev-parse", commit_to_check]
log.debug(
"Running `%s` to get the full commit hash for %s",
" ".join(cmd),
commit_to_check
)
output = SCM._run(cmd, chdir=td)[1]
finally:
if td and os.path.exists(td):
shutil.rmtree(td)

View File

@@ -105,7 +105,10 @@ def _scm_get_latest(pkg):
# we want to pull from, we need to resolve that f25 branch
# to the specific commit available at the time of
# submission (now).
pkgref = module_build_service.scm.SCM(pkg.get_repository()).get_latest(pkg.get_ref())
repo = pkg.get_repository()
ref = pkg.get_ref()
log.debug("Getting the commit hash for the ref %s on the repo %s", ref, repo)
pkgref = module_build_service.scm.SCM(repo).get_latest(ref)
except Exception as e:
log.exception(e)
return {