Fix broken reference based git import

Fixes #130
This commit is contained in:
rubenwardy 2019-08-31 22:09:19 +01:00
parent 655ed2255a
commit cc564af44e
1 changed files with 5 additions and 3 deletions

View File

@ -299,15 +299,17 @@ def cloneRepo(urlstr, ref=None, recursive=False):
gitUrl = generateGitURL(urlstr)
print("Cloning from " + gitUrl)
repo = git.Repo.clone_from(gitUrl, gitDir, \
progress=None, env=None, depth=1, recursive=recursive, kill_after_timeout=15)
progress=None, env=None, depth=1, recursive=recursive, kill_after_timeout=15, b=ref)
if ref is not None:
repo.create_head("myhead", ref).checkout()
return gitDir, repo
except GitCommandError as e:
# This is needed to stop the backtrace being weird
err = e.stderr
except gitdb.exc.BadName as e:
err = "Unable to find the reference " + (ref or "?") + "\n" + e.stderr
raise TaskError(err.replace("stderr: ", "") \
.replace("Cloning into '" + gitDir + "'...", "") \
.strip())