mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
apps: fix trick to find the default branch from git repo @_@
This commit is contained in:
parent
f21fbed2f7
commit
25c10166cf
1 changed files with 10 additions and 6 deletions
16
src/app.py
16
src/app.py
|
@ -2382,20 +2382,24 @@ def _extract_app_from_gitrepo(
|
|||
logger.debug("Checking default branch")
|
||||
|
||||
try:
|
||||
git_remote_show = check_output(
|
||||
["git", "remote", "show", url],
|
||||
git_ls_remote = check_output(
|
||||
["git", "ls-remote", "--symref", url, "HEAD"],
|
||||
env={"GIT_TERMINAL_PROMPT": "0", "LC_ALL": "C"},
|
||||
shell=False,
|
||||
)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.error(str(e))
|
||||
raise YunohostError("app_sources_fetch_failed")
|
||||
|
||||
if not branch:
|
||||
default_branch = None
|
||||
try:
|
||||
for line in git_remote_show.split("\n"):
|
||||
if "HEAD branch:" in line:
|
||||
default_branch = line.split()[-1]
|
||||
for line in git_ls_remote.split("\n"):
|
||||
# Look for the line formated like :
|
||||
# ref: refs/heads/master HEAD
|
||||
if "ref: refs/heads/" in line:
|
||||
line = line.replace("/", " ").replace("\t", " ")
|
||||
default_branch = line.split()[3]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue