From 83bc780a2313bd77e387eef320a841aaa1cca73b Mon Sep 17 00:00:00 2001 From: mprahl Date: Apr 11 2019 14:23:12 +0000 Subject: Add backwards-compatibility for cloning local repos with the artifact name and not the full path This addresses #1211 --- diff --git a/module_build_service/builder/MockModuleBuilder.py b/module_build_service/builder/MockModuleBuilder.py index 19993e9..e87d6cf 100644 --- a/module_build_service/builder/MockModuleBuilder.py +++ b/module_build_service/builder/MockModuleBuilder.py @@ -591,14 +591,10 @@ class SCMBuilder(BaseBuilder): def __init__(self, config, resultsdir, source, artifact_name): super(SCMBuilder, self).__init__(config, resultsdir) with open(config, "a") as f: - git_repo, branch = source.split("?#") + repo_path, branch = source.split("?#") distgit_cmds = self._get_distgit_commands(source) - - if source.startswith("file://"): - # For local git repositories, pass the full path to repository to git command. - distgit_get = distgit_cmds[0].format(git_repo) - else: - distgit_get = distgit_cmds[0].format(artifact_name) + # Supply the artifact name for "{0}" and the full path to the repo for "{repo_path}" + distgit_get = distgit_cmds[0].format(artifact_name, repo_path=repo_path) # mock-scm cannot checkout particular commit hash, but only branch. # We therefore use a command that combines the distgit-command with @@ -631,8 +627,8 @@ class SCMBuilder(BaseBuilder): # local builds. # Instead, get them from local path with git repository by passing that path to Mock # using the `ext_src_dir`. - if git_repo.startswith("file://"): - src_dir = git_repo[len("file://"):] + if repo_path.startswith("file://"): + src_dir = repo_path[len("file://"):] f.write("config_opts['scm_opts']['ext_src_dir'] = '{}'\n".format(src_dir)) def _make_executable(self, path): diff --git a/module_build_service/config.py b/module_build_service/config.py index fb91850..1308f48 100644 --- a/module_build_service/config.py +++ b/module_build_service/config.py @@ -336,7 +336,7 @@ class Config(object): 'default': { 'https://src.fedoraproject.org': ('fedpkg clone --anonymous {}', 'fedpkg --release module sources'), - 'file://': ('git clone {}', None), + 'file://': ('git clone {repo_path}', None), }, 'desc': 'Mapping between dist-git and command to '}, 'mock_config': {