Send the actual branch to copr, not commit

This commit is contained in:
Jakub Kadlcik
2017-07-24 23:30:24 +02:00
parent 33010a83bd
commit 6e6de42d0d

View File

@@ -257,9 +257,12 @@ class CoprModuleBuilder(GenericBuilder):
return self.client.create_new_build(self.copr.projectname, [source], username=self.copr.username)
def build_scm(self, source):
url, branch = source.split("?#")
url, commit = source.split("?#")
url = (url.replace("git://", "https://")
.replace("pkgs.fedoraproject.org", "src.fedoraproject.org/git"))
cod = clone(url)
branch = git_branch_contains(cod, commit)
rmdir(cod)
return self.client.create_new_build_distgit(self.copr.projectname, url, branch=branch, username=self.copr.username)
def finalize(self):
@@ -382,6 +385,23 @@ def build_from_scm(artifact_name, source, config, build_srpm,
return ret
def clone(url):
log.debug('Cloning source URL: %s' % url)
td = tempfile.mkdtemp()
scm = module_build_service.scm.SCM(url)
return scm.checkout(td)
def rmdir(path):
try:
if path is not None:
shutil.rmtree(path)
except Exception as e:
log.warning(
"Failed to remove temporary directory {!r}: {}".format(
path, str(e)))
def git_branch_contains(cod, commit):
cmd = ["git", "branch", "-r", "--contains", commit]
out, err = execute_cmd(cmd, cwd=cod, stdout=subprocess.PIPE, stderr=subprocess.PIPE)