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")
|
logger.debug("Checking default branch")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
git_remote_show = check_output(
|
git_ls_remote = check_output(
|
||||||
["git", "remote", "show", url],
|
["git", "ls-remote", "--symref", url, "HEAD"],
|
||||||
env={"GIT_TERMINAL_PROMPT": "0", "LC_ALL": "C"},
|
env={"GIT_TERMINAL_PROMPT": "0", "LC_ALL": "C"},
|
||||||
shell=False,
|
shell=False,
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
|
logger.error(str(e))
|
||||||
raise YunohostError("app_sources_fetch_failed")
|
raise YunohostError("app_sources_fetch_failed")
|
||||||
|
|
||||||
if not branch:
|
if not branch:
|
||||||
default_branch = None
|
default_branch = None
|
||||||
try:
|
try:
|
||||||
for line in git_remote_show.split("\n"):
|
for line in git_ls_remote.split("\n"):
|
||||||
if "HEAD branch:" in line:
|
# Look for the line formated like :
|
||||||
default_branch = line.split()[-1]
|
# ref: refs/heads/master HEAD
|
||||||
|
if "ref: refs/heads/" in line:
|
||||||
|
line = line.replace("/", " ").replace("\t", " ")
|
||||||
|
default_branch = line.split()[3]
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue