From dc67cd9d2c836305cac07125d91937008d2f16c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 11 Feb 2025 08:43:03 +0100 Subject: [PATCH 1/2] Retry from scratch on fetch error --- app/shared_config_manager/sources/git.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/shared_config_manager/sources/git.py b/app/shared_config_manager/sources/git.py index 325fa878..c88bceca 100644 --- a/app/shared_config_manager/sources/git.py +++ b/app/shared_config_manager/sources/git.py @@ -2,7 +2,9 @@ import json import logging import os +import subprocess import tempfile +from pathlib import Path from shared_config_manager.configuration import SourceStatus from shared_config_manager.sources import mode @@ -26,11 +28,17 @@ def _checkout(self) -> None: cwd = self._clone_dir() repo = self._get_repo() branch = self.get_branch() - if os.path.isdir(os.path.join(cwd, ".git")): + git_dir = Path(cwd) / ".git" + if git_dir.is_dir(): LOG.info("Fetching a new version of %s", repo) - self._exec("git", "fetch", "--depth=1", "origin", branch, cwd=cwd) - self._exec("git", "checkout", branch, cwd=cwd) - self._exec("git", "reset", "--hard", f"origin/{branch}", cwd=cwd) + try: + self._exec("git", "fetch", "--depth=1", "origin", branch, cwd=cwd) + self._exec("git", "checkout", branch, cwd=cwd) + self._exec("git", "reset", "--hard", f"origin/{branch}", cwd=cwd) + except subprocess.CalledProcessError: + LOG.warning("Failed to fetch a new version of %s, retry checkout", repo) + self._exec("rm", "-rf", git_dir) + self._checkout() elif self._do_sparse(): LOG.info("Cloning %s (sparse)", repo) self._exec("git-sparse-clone", repo, branch, cwd, self._config["sub_dir"], cwd=TEMP_DIR) From eddf47133d54aab95696a45d5b698417ff550d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 11 Feb 2025 09:01:09 +0100 Subject: [PATCH 2/2] Fix dpkg packages diff --- .github/workflows/main.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 38df0db2..e66252c9 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -86,6 +86,7 @@ jobs: - run: c2cciutils-docker-logs if: failure() + - run: git reset --hard - name: Publish run: c2cciutils-publish if: env.HAS_SECRETS == 'HAS_SECRETS'