mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-14 09:09:44 +08:00
Merge #204 Resolve component refs on build submission.
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