Revert "Fix Git clone error when checking out reference"

This reverts commit 63cfb5eac0.
This commit is contained in:
rubenwardy
2021-03-02 16:42:38 +00:00
parent 63cfb5eac0
commit c11e5c1f99
2 changed files with 20 additions and 5 deletions

View File

@@ -40,13 +40,28 @@ def get_temp_dir():
# Throws `TaskError` on failure.
# Caller is responsible for deleting returned directory.
@contextlib.contextmanager
def clone_repo(urlstr, ref=None):
def clone_repo(urlstr, ref=None, recursive=False):
gitDir = os.path.join(tempfile.gettempdir(), randomString(10))
err = None
try:
gitUrl = generateGitURL(urlstr)
repo = git.Repo.clone_from(gitUrl, gitDir, b=ref,
progress=None, env=None, depth=1, recursive=True, kill_after_timeout=15)
print("Cloning from " + gitUrl)
if ref is None:
repo = git.Repo.clone_from(gitUrl, gitDir,
progress=None, env=None, depth=1, recursive=recursive, kill_after_timeout=15)
else:
assert ref != ""
repo = git.Repo.init(gitDir)
origin = repo.create_remote("origin", url=gitUrl)
assert origin.exists()
origin.fetch()
repo.git.checkout(ref)
for submodule in repo.submodules:
submodule.update(init=True)
yield repo
shutil.rmtree(gitDir)