From 66bd078e7f271c3eec6be2dd4c9065c9f0b3f7f3 Mon Sep 17 00:00:00 2001 From: Pascal Bach Date: Wed, 19 Jun 2019 10:49:44 +0200 Subject: [PATCH] repos: make sure the remote url is matching the kas file Currently the the remote URL is only set during the initial clone. This might lead to confusion with the user as changing the URL in the kas.yml does not get reflected and thus errors about references not found show up. This change makes sure the URL is always set to the value specified in the kas.yml file. For mercurial this currently prints a warning as there is no command to change the default path. Signed-off-by: Pascal Bach [Jan: fix up style, adjust comment on hg's set_remote_url_cmd] Signed-off-by: Jan Kiszka --- kas/repos.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/kas/repos.py b/kas/repos.py index 06c922c..689be7b 100644 --- a/kas/repos.py +++ b/kas/repos.py @@ -175,6 +175,22 @@ class RepoImpl(Repo): logging.info('Repository %s cloned', self.name) return retc + # Make sure the remote origin is set to the value + # in the kas file to avoid suprises + try: + (retc, output) = yield from run_cmd_async( + self.set_remote_url_cmd(), + cwd=self.path, + fail=False, + liveupdate=False) + if retc != 0: + logging.info('Changing remote URL to %s failed with error: %s', + self.effective_url, output.strip()) + return retc + except NotImplementedError: + logging.warning('Repo implementation does not support changing ' + 'the remote url.') + # take what came out of clone and stick to that forever if self.refspec is None: return 0 @@ -312,6 +328,9 @@ class GitRepo(RepoImpl): return ['git', 'quiltimport', '--author', 'kas ', '--patches', path] + def set_remote_url_cmd(self): + return ['git', 'remote', 'set-url', 'origin', self.effective_url] + class MercurialRepo(RepoImpl): """ @@ -341,3 +360,7 @@ class MercurialRepo(RepoImpl): def apply_patches_quilt_cmd(self, path): raise NotImplementedError() + + def set_remote_url_cmd(self, url): + # TODO + raise NotImplementedError()