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 <hlin@redhat.com>
This commit is contained in:
Haibo Lin 2020-09-10 09:53:17 +08:00
parent c6312b34d0
commit b3a55fd863
2 changed files with 3 additions and 0 deletions

View File

@ -168,6 +168,8 @@ class GitWrapper(ScmBase):
% (e, e.output) % (e, e.output)
) )
try: 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) run(["git", "remote", "add", "origin", repo], workdir=destdir)
self.retry_run(["git", "remote", "update", "origin"], workdir=destdir) self.retry_run(["git", "remote", "update", "origin"], workdir=destdir)
run(["git", "checkout", branch], workdir=destdir) run(["git", "checkout", branch], workdir=destdir)

View File

@ -192,6 +192,7 @@ class GitSCMTestCase(SCMBaseTest):
"git://example.com/git/repo.git", "git://example.com/git/repo.git",
"master", "master",
], ],
["git", "init"],
["git", "remote", "add", "origin", url], ["git", "remote", "add", "origin", url],
["git", "remote", "update", "origin"], ["git", "remote", "update", "origin"],
["git", "checkout", "master"], ["git", "checkout", "master"],