mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-08 22:17:34 +01:00
Fix default branch detection
This commit is contained in:
parent
e8dca43f44
commit
b613ac4b89
@ -1,5 +1,5 @@
|
|||||||
# ContentDB
|
# ContentDB
|
||||||
# Copyright (C) 2018 rubenwardy
|
# Copyright (C) 2018-21 rubenwardy
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -88,22 +88,20 @@ def clone_repo(urlstr, ref=None, recursive=False):
|
|||||||
.strip())
|
.strip())
|
||||||
|
|
||||||
|
|
||||||
def get_commit_hash(urlstr, ref_name=None):
|
def get_commit_hash(git_url, ref_name=None):
|
||||||
gitDir = os.path.join(tempfile.gettempdir(), randomString(10))
|
|
||||||
gitUrl = generateGitURL(urlstr)
|
|
||||||
assert ref_name != ""
|
|
||||||
|
|
||||||
repo = git.Repo.init(gitDir)
|
|
||||||
origin: git.Remote = repo.create_remote("origin", url=gitUrl)
|
|
||||||
assert origin.exists()
|
|
||||||
origin.fetch()
|
|
||||||
|
|
||||||
if ref_name:
|
if ref_name:
|
||||||
ref: git.Reference = origin.refs[ref_name]
|
ref_name = "refs/heads/" + ref_name
|
||||||
else:
|
else:
|
||||||
ref: git.Reference = origin.refs[0]
|
ref_name = "HEAD"
|
||||||
|
|
||||||
return ref.commit.hexsha
|
g = git.cmd.Git()
|
||||||
|
|
||||||
|
remote_refs = {}
|
||||||
|
for ref in g.ls_remote(git_url).split('\n'):
|
||||||
|
hash_ref_list = ref.split('\t')
|
||||||
|
remote_refs[hash_ref_list[1]] = hash_ref_list[0]
|
||||||
|
|
||||||
|
return remote_refs.get(ref_name)
|
||||||
|
|
||||||
|
|
||||||
@celery.task()
|
@celery.task()
|
||||||
|
@ -31,7 +31,7 @@ future==0.18.2
|
|||||||
git-archive-all==1.21.0
|
git-archive-all==1.21.0
|
||||||
gitdb==4.0.5
|
gitdb==4.0.5
|
||||||
GitHub-Flask==3.2.0
|
GitHub-Flask==3.2.0
|
||||||
GitPython==3.1.7
|
GitPython==3.1.9
|
||||||
gunicorn==20.0.4
|
gunicorn==20.0.4
|
||||||
idna==2.10
|
idna==2.10
|
||||||
importlib-metadata==1.7.0
|
importlib-metadata==1.7.0
|
||||||
|
Loading…
Reference in New Issue
Block a user