Simplify code (suggestion from Bram)

This commit is contained in:
Alexandre Aubin 2020-09-16 19:28:45 +02:00
parent 56ebb06d2b
commit d5f8eb06c8

View file

@ -60,12 +60,6 @@ APPS_CATALOG_CRON_PATH = "/etc/cron.daily/yunohost-fetch-apps-catalog"
APPS_CATALOG_API_VERSION = 2 APPS_CATALOG_API_VERSION = 2
APPS_CATALOG_DEFAULT_URL = "https://app.yunohost.org/default" APPS_CATALOG_DEFAULT_URL = "https://app.yunohost.org/default"
re_github_repo = re.compile(
r'^(http[s]?://|git@)github.com[/:]'
'(?P<owner>[\w\-_]+)/(?P<repo>[\w\-_]+)(.git)?'
'(/tree/(?P<tree>.+))?'
)
re_app_instance_name = re.compile( re_app_instance_name = re.compile(
r'^(?P<appid>[\w-]+?)(__(?P<appinstancenb>[1-9][0-9]*))?$' r'^(?P<appid>[\w-]+?)(__(?P<appinstancenb>[1-9][0-9]*))?$'
) )
@ -2242,10 +2236,8 @@ def _fetch_app_from_git(app):
if ('@' in app) or ('http://' in app) or ('https://' in app): if ('@' in app) or ('http://' in app) or ('https://' in app):
url = app url = app
branch = 'master' branch = 'master'
tree_index = url.rfind('/tree/') if "/tree/" in url:
if tree_index > 0: url, branch = url.split("/tree/", 1)
url = url[:tree_index]
branch = app[tree_index + 6:]
revision = 'HEAD' revision = 'HEAD'
else: else:
app_dict = _load_apps_catalog()["apps"] app_dict = _load_apps_catalog()["apps"]