From b3a55fd863f4e2e686ef06f6fa8ee6d2bbd7dd3c Mon Sep 17 00:00:00 2001 From: Haibo Lin Date: Thu, 10 Sep 2020 09:53:17 +0800 Subject: [PATCH] gitwrapper: Re-run git init before do full clone Sometimes full clone failed with error fatal: Not a git repository and we found that .git/refs/ dir is missing after shallow clone failed. JIRA: RHELCMP-724 Signed-off-by: Haibo Lin --- pungi/wrappers/scm.py | 2 ++ tests/test_scm.py | 1 + 2 files changed, 3 insertions(+) diff --git a/pungi/wrappers/scm.py b/pungi/wrappers/scm.py index 1f464295..a099a902 100644 --- a/pungi/wrappers/scm.py +++ b/pungi/wrappers/scm.py @@ -168,6 +168,8 @@ class GitWrapper(ScmBase): % (e, e.output) ) try: + # Re-run git init in case of previous failure breaking .git dir + run(["git", "init"], workdir=destdir) run(["git", "remote", "add", "origin", repo], workdir=destdir) self.retry_run(["git", "remote", "update", "origin"], workdir=destdir) run(["git", "checkout", branch], workdir=destdir) diff --git a/tests/test_scm.py b/tests/test_scm.py index 1cb7f35f..ae18985f 100644 --- a/tests/test_scm.py +++ b/tests/test_scm.py @@ -192,6 +192,7 @@ class GitSCMTestCase(SCMBaseTest): "git://example.com/git/repo.git", "master", ], + ["git", "init"], ["git", "remote", "add", "origin", url], ["git", "remote", "update", "origin"], ["git", "checkout", "master"],