1
0
Fork 0
mirror of https://github.com/YunoHost/apps.git synced 2024-09-03 20:06:07 +02:00

Support other branches than master?

This commit is contained in:
Alexandre Aubin 2020-05-14 17:58:24 +00:00
parent 20764430b9
commit 6973052497

View file

@ -80,7 +80,12 @@ def init_cache(app, infos):
else:
depth = 40
git("clone --quiet --depth {depth} --single-branch --branch master {url} {folder}".format(depth=depth, url=infos["url"], folder=app_cache_folder(app)))
git("clone --quiet --depth {depth} --single-branch --branch {branch} {url} {folder}".format(
depth=depth,
url=infos["url"],
branch=infos.get("branch", "master"),
folder=app_cache_folder(app))
)
def refresh_cache(app, infos):
@ -90,10 +95,12 @@ def refresh_cache(app, infos):
if os.path.exists(fetch_head) and now - os.path.getmtime(fetch_head) < 3600:
return
branch=infos.get("branch", "master")
try:
git("remote set-url origin " + infos["url"], in_folder=app_cache_folder(app))
git("fetch --quiet origin master --force", in_folder=app_cache_folder(app))
git("reset origin/master --hard", 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))
except:
# Sometimes there are tmp issue such that the refresh cache ..
# we don't trigger an error unless the cache hasnt been updated since more than 24 hours
@ -160,8 +167,6 @@ def build_catalog():
def build_app_dict(app, infos):
assert infos["branch"] == "master"
# Make sure we have some cache
this_app_cache = app_cache_folder(app)
assert os.path.exists(this_app_cache), "No cache yet for %s" % app