From 663e43ca8a382a5058b158a5f6e0abf2d4819bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Dachary?= Date: Sat, 2 Jul 2022 14:32:25 +0200 Subject: [PATCH] always clone the fleet repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is small and not worth the trouble of dealing with fetch/pull Signed-off-by: Loïc Dachary --- infrastructure/utils.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/infrastructure/utils.py b/infrastructure/utils.py index c022f85..cf7bcd6 100644 --- a/infrastructure/utils.py +++ b/infrastructure/utils.py @@ -116,10 +116,11 @@ class Infra: ssh_cmd = f"/usr/bin/ssh -oStrictHostKeyChecking=no -i {conf['SSH_KEY']}" self.env = {"GIT_SSH_COMMAND": ssh_cmd} - try: - self.repo = Repo(path=self.repo_path) - except InvalidGitRepositoryError: - self.repo = Repo.clone_from(conf["REMOTE"], self.repo_path, env=self.env) + self._clone() + + def _clone(self): + shutil.rmtree(self.repo_path) + self.repo = Repo.clone_from(conf["REMOTE"], self.repo_path, env=self.env) def _host_vars_dir(self, subdomain: str) -> Path: """ @@ -227,11 +228,6 @@ class Infra: author="Dashboard Bot ", ) - def _pull(self): - self.repo.git.fetch(env=self.env) - - # TODO: switch to using Git cmd - @staticmethod def translate_size(instance: Instance) -> str: """ @@ -252,7 +248,7 @@ class Infra: The gitea user password is returned """ - self._pull() + self._clone() subdomain = instance.name host_vars_dir = self._host_vars_dir(subdomain) @@ -331,7 +327,7 @@ class Infra: """ Remove a VM from infrastructure repository """ - self._pull() + self._clone() subdomain = instance.name try: