Merge pull request #971 from YunoHost/fix-cache

add branch when the needed one is not tracked
This commit is contained in:
Kayou 2020-08-23 19:29:43 +02:00 committed by GitHub
commit 4b954f54be

View file

@ -99,6 +99,15 @@ def refresh_cache(app, infos):
try: try:
git("remote set-url origin " + infos["url"], in_folder=app_cache_folder(app)) git("remote set-url origin " + infos["url"], in_folder=app_cache_folder(app))
current_branch = git("branch --show-current", in_folder=app_cache_folder(app))
if current_branch != branch:
all_branches = git("branch --format=%(refname:short)", in_folder=app_cache_folder(app)).split()
if branch not in all_branches:
git("remote set-branches --add origin %s" % branch, in_folder=app_cache_folder(app))
git("fetch origin %s:%s" % (branch, branch), in_folder=app_cache_folder(app))
else:
git("checkout --force %s" % branch, in_folder=app_cache_folder(app))
git("fetch --quiet origin %s --force" % branch, in_folder=app_cache_folder(app)) git("fetch --quiet origin %s --force" % branch, in_folder=app_cache_folder(app))
git("reset origin/%s --hard" % branch, in_folder=app_cache_folder(app)) git("reset origin/%s --hard" % branch, in_folder=app_cache_folder(app))
except: except: