Don't hardcode dist-git clone command

This commit is contained in:
Jakub Kadlčík
2017-05-16 16:26:24 +02:00
parent 4c23e56181
commit 8c8ea65b2e
2 changed files with 13 additions and 2 deletions

View File

@@ -446,13 +446,18 @@ class SCMBuilder(BaseBuilder):
super(SCMBuilder, self).__init__(config, resultsdir)
with open(config, "a") as f:
branch = source.split("?#")[1]
dist_git_get = self._get_clone_command(source).format(artifact_name)
f.writelines([
"config_opts['scm'] = True\n",
"config_opts['scm_opts']['method'] = 'distgit'\n",
"config_opts['scm_opts']['branch'] = '{}'\n".format(branch),
"config_opts['scm_opts']['package'] = '{}'\n".format(artifact_name),
"config_opts['scm_opts']['distgit_get'] = 'fedpkg clone {} --anonymous'\n".format(artifact_name),
"config_opts['scm_opts']['distgit_get'] = '{}'\n".format(dist_git_get),
"config_opts['scm_opts']['distgit_src_get'] = 'fedpkg sources'\n",
])
def _get_clone_command(self, source):
for host, cmd in conf.distgits.items():
if source.startswith(host):
return cmd
raise KeyError("No defined command for {}".format(source))

View File

@@ -286,6 +286,12 @@ class Config(object):
'type': str,
'default': '',
'desc': 'Trusted certificate for ssl connection.'},
'distgits': {
'type': dict,
'default': {
'git://pkgs.fedoraproject.org': 'fedpkg clone --anonymous {}',
},
'desc': 'Mapping between dist-git and command to '},
'mock_config': {
'type': str,
'default': 'fedora-25-x86_64',