mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Fix Git clone error when checking out reference
This commit is contained in:
parent
6861524641
commit
63cfb5eac0
@ -31,7 +31,7 @@ from ..logic.packages import do_edit_package, ALIASES
|
||||
|
||||
@celery.task()
|
||||
def getMeta(urlstr, author):
|
||||
with clone_repo(urlstr, recursive=True) as repo:
|
||||
with clone_repo(urlstr) as repo:
|
||||
try:
|
||||
tree = build_tree(repo.working_tree_dir, author=author, repo=urlstr)
|
||||
except MinetestCheckError as err:
|
||||
@ -162,7 +162,7 @@ def makeVCSRelease(self, id, branch):
|
||||
elif release.package is None:
|
||||
raise TaskError("No package attached to release")
|
||||
|
||||
with clone_repo(release.package.repo, ref=branch, recursive=True) as repo:
|
||||
with clone_repo(release.package.repo, branch) as repo:
|
||||
postReleaseCheckUpdate(self, release, repo.working_tree_dir)
|
||||
|
||||
filename = randomString(10) + ".zip"
|
||||
|
@ -40,28 +40,13 @@ def get_temp_dir():
|
||||
# Throws `TaskError` on failure.
|
||||
# Caller is responsible for deleting returned directory.
|
||||
@contextlib.contextmanager
|
||||
def clone_repo(urlstr, ref=None, recursive=False):
|
||||
def clone_repo(urlstr, ref=None):
|
||||
gitDir = os.path.join(tempfile.gettempdir(), randomString(10))
|
||||
|
||||
err = None
|
||||
try:
|
||||
gitUrl = generateGitURL(urlstr)
|
||||
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)
|
||||
repo = git.Repo.clone_from(gitUrl, gitDir, b=ref,
|
||||
progress=None, env=None, depth=1, recursive=True, kill_after_timeout=15)
|
||||
|
||||
yield repo
|
||||
shutil.rmtree(gitDir)
|
||||
|
Loading…
Reference in New Issue
Block a user