Keep and use the full scm url instead of reconstructing it.

This commit is contained in:
Ralph Bean
2016-07-20 14:42:56 -04:00
parent 544b99ba09
commit d08c7b936b
4 changed files with 14 additions and 12 deletions

View File

@@ -133,13 +133,14 @@ def submit_build():
pkg["commit"] = rida.scm.SCM(pkg["repository"]).get_latest()
except Exception as e:
return failure("Failed to get the latest commit: %s" % pkgname, 422)
if not rida.scm.SCM(pkg["repository"] + "?#" + pkg["commit"]).is_available():
full_url = pkg["repository"] + "?#" + pkg["commit"]
if not rida.scm.SCM(full_url).is_available():
return failure("Cannot checkout %s" % pkgname, 422)
build = rida.database.ComponentBuild(
module_id=module.id,
package=pkgname,
format="rpms",
gitref=pkg["commit"], # TODO - re-evaluate this w.r.t. supported branches
scmurl=full_url,
)
db.session.add(build)
module.modulemd = mmd.dumps()

View File

@@ -229,7 +229,7 @@ class ComponentBuild(Base):
__tablename__ = "component_builds"
id = Column(Integer, primary_key=True)
package = Column(String, nullable=False)
gitref = Column(String, nullable=False)
scmurl = Column(String, nullable=False)
# XXX: Consider making this a proper ENUM
format = Column(String, nullable=False)
task_id = Column(Integer) # This is the id of the build in koji

View File

@@ -53,12 +53,13 @@ def done(config, session, msg):
builder.buildroot_resume()
for component_build in unbuilt_components:
scmurl = "{dist_git}/{package}?#{gitref}".format(
dist_git=config.rpms_default_repository,
package=component_build.package,
gitref=component_build.gitref, # This is the update stream
)
component_build.state = koji.BUILD_STATES['BUILDING']
log.debug("Using scmurl=%s for package=%s" % (scmurl, component_build.package))
component_build.task_id = builder.build(artifact=component_build.package, source=scmurl)
log.debug("Using scmurl=%s for package=%s" % (
component_build.scmurl,
component_build.package,
))
component_build.task_id = builder.build(
artifact=component_build.package,
source=component_build.scmurl,
)
session.commit()

View File

@@ -58,7 +58,7 @@ class TestRepoDone(unittest.TestCase):
"""
component_build = mock.Mock()
component_build.package = 'foo'
component_build.gitref = 'beef'
component_build.scmurl = 'full_scm_url'
component_build.state = None
module_build = mock.Mock()
module_build.component_builds = [component_build]
@@ -69,4 +69,4 @@ class TestRepoDone(unittest.TestCase):
'msg': {'tag': 'no matches for this...'},
}
self.fn(config=self.config, session=self.session, msg=msg)
build_fn.assert_called_once_with('TODO', 'dist_git_url/rpms/foo?#beef')
build_fn.assert_called_once_with('TODO', 'full_scm_url')