From 25c10166cfc078461d0ef23c4dff201d231f5abb Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 10 Jan 2023 00:48:39 +0100 Subject: [PATCH] apps: fix trick to find the default branch from git repo @_@ --- src/app.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/app.py b/src/app.py index fe49932f0..7458808fc 100644 --- a/src/app.py +++ b/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