mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-11-28 15:14:32 +08:00
Resolve component refs on build submission.
Fixes #203. The modulemd files we had used to all pin the commit hashes of the components they were pulling in. We changed this with modulemd-1.0 and now modules can define their components in terms of their *stream* (a.k.a. their dist-git *branch*). This is awesome, and is a big stepping stone towards greater things. The problem is that we used to take that git ref literally from the modulemd and pass it on to koji. Now that instead we are passing on a branch name to koji, it falls down. Koji requires us to send it an explicit commit hash. This change takes that branch name and converts it to an explicit commit hash when the module is first submitted. Verified that things are working again: - http://koji.stg.fedoraproject.org/koji/taskinfo?taskID=90084980
This commit is contained in:
@@ -140,10 +140,10 @@ class SCM(object):
|
||||
raise RuntimeError("checkout: Unhandled SCM scheme.")
|
||||
return sourcedir
|
||||
|
||||
def get_latest(self):
|
||||
def get_latest(self, branch='master'):
|
||||
"""Get the latest commit ID.
|
||||
|
||||
:returns: str -- the latest commit ID, e.g. the git master HEAD
|
||||
:returns: str -- the latest commit ID, e.g. the git $BRANCH HEAD
|
||||
:raises: RuntimeError
|
||||
"""
|
||||
if self.scheme == "git":
|
||||
@@ -151,13 +151,16 @@ class SCM(object):
|
||||
proc = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
|
||||
output, stderr = proc.communicate()
|
||||
if proc.returncode != 0:
|
||||
raise RuntimeError("Cannot get git hash of master HEAD in %s"
|
||||
% self.repository)
|
||||
raise RuntimeError("Cannot get git hash of %s HEAD in %s"
|
||||
% (branch, self.repository))
|
||||
for line in output.split(os.linesep):
|
||||
if line.endswith("\trefs/heads/master"):
|
||||
if line.endswith("\trefs/heads/%s" % branch):
|
||||
return line.split("\t")[0]
|
||||
raise RuntimeError("Couldn't determine the git master HEAD hash in %s"
|
||||
% self.repository)
|
||||
|
||||
# Hopefully `branch` is really a commit hash. Code later needs to verify this.
|
||||
log.warn("Couldn't determine the git %s HEAD hash in %s."
|
||||
% (branch, self.repository))
|
||||
return branch
|
||||
else:
|
||||
raise RuntimeError("get_latest: Unhandled SCM scheme.")
|
||||
|
||||
|
||||
@@ -294,12 +294,18 @@ def submit_module_build(username, url):
|
||||
if not pkg.cache:
|
||||
pkg.cache = conf.rpms_default_cache + pkgname
|
||||
if not pkg.ref:
|
||||
try:
|
||||
pkg.ref = module_build_service.scm.SCM(
|
||||
pkg.repository).get_latest()
|
||||
except Exception as e:
|
||||
raise UnprocessableEntity(
|
||||
"Failed to get the latest commit: %s" % pkgname)
|
||||
pkg.ref = 'master'
|
||||
try:
|
||||
# If the modulemd specifies that the 'f25' branch is what
|
||||
# we want to pull from, we need to resolve that f25 branch
|
||||
# to the specific commit available at the time of
|
||||
# submission (now).
|
||||
pkg.ref = module_build_service.scm.SCM(
|
||||
pkg.repository).get_latest(branch=pkg.ref)
|
||||
except Exception as e:
|
||||
raise UnprocessableEntity(
|
||||
"Failed to get the latest commit for %s#%s" % (
|
||||
pkgname, pkg.ref))
|
||||
except Exception:
|
||||
module.transition(conf, models.BUILD_STATES["failed"])
|
||||
db.session.add(module)
|
||||
|
||||
Reference in New Issue
Block a user