mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-10 23:17:37 +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()
|
@celery.task()
|
||||||
def getMeta(urlstr, author):
|
def getMeta(urlstr, author):
|
||||||
with clone_repo(urlstr, recursive=True) as repo:
|
with clone_repo(urlstr) as repo:
|
||||||
try:
|
try:
|
||||||
tree = build_tree(repo.working_tree_dir, author=author, repo=urlstr)
|
tree = build_tree(repo.working_tree_dir, author=author, repo=urlstr)
|
||||||
except MinetestCheckError as err:
|
except MinetestCheckError as err:
|
||||||
@ -162,7 +162,7 @@ def makeVCSRelease(self, id, branch):
|
|||||||
elif release.package is None:
|
elif release.package is None:
|
||||||
raise TaskError("No package attached to release")
|
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)
|
postReleaseCheckUpdate(self, release, repo.working_tree_dir)
|
||||||
|
|
||||||
filename = randomString(10) + ".zip"
|
filename = randomString(10) + ".zip"
|
||||||
|
@ -40,28 +40,13 @@ def get_temp_dir():
|
|||||||
# Throws `TaskError` on failure.
|
# Throws `TaskError` on failure.
|
||||||
# Caller is responsible for deleting returned directory.
|
# Caller is responsible for deleting returned directory.
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def clone_repo(urlstr, ref=None, recursive=False):
|
def clone_repo(urlstr, ref=None):
|
||||||
gitDir = os.path.join(tempfile.gettempdir(), randomString(10))
|
gitDir = os.path.join(tempfile.gettempdir(), randomString(10))
|
||||||
|
|
||||||
err = None
|
|
||||||
try:
|
try:
|
||||||
gitUrl = generateGitURL(urlstr)
|
gitUrl = generateGitURL(urlstr)
|
||||||
print("Cloning from " + gitUrl)
|
repo = git.Repo.clone_from(gitUrl, gitDir, b=ref,
|
||||||
|
progress=None, env=None, depth=1, recursive=True, kill_after_timeout=15)
|
||||||
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
|
yield repo
|
||||||
shutil.rmtree(gitDir)
|
shutil.rmtree(gitDir)
|
||||||
|
Loading…
Reference in New Issue
Block a user