[Fix] Commit is empty

This commit is contained in:
Kay0u 2019-12-18 21:14:44 +08:00
parent 9fd1a224f8
commit 83c38fa43e

View file

@ -164,7 +164,7 @@ for app, info in apps_list.items():
elif forge_site == "framagit.org": elif forge_site == "framagit.org":
forge_type = "gitlab" forge_type = "gitlab"
elif forge_site == "code.ffdn.org": elif forge_site == "code.ffdn.org":
forge_type = "gogs" forge_type = "gitlab"
elif forge_site == "code.antopie.org": elif forge_site == "code.antopie.org":
forge_type = "gitea" forge_type = "gitea"
else: else:
@ -284,8 +284,25 @@ for app, info in apps_list.items():
commit_date = parse(commit["authored_date"]) commit_date = parse(commit["authored_date"])
timestamp = int(time.mktime(commit_date.timetuple())) timestamp = int(time.mktime(commit_date.timetuple()))
elif forge_type == "gitea":
raw_url = 'https://%s/%s/%s/raw/commit/%s/manifest.json' % (forge_site, owner, repo, app_rev)
manifest = get_json(raw_url, verify=True)
if manifest is None:
error("Manifest is empty for app %s ?" % app)
continue
api_url = 'https://%s/api/v1/repos/%s/%s/git/commits/%s' % (forge_site, owner, repo, app_rev)
info2 = get_json(api_url)
if info2 is None:
error("Commit info is empty for app %s ?" % app)
continue
commit_date = parse(info2['commit']['author']['date'])
timestamp = int(time.mktime(commit_date.timetuple()))
# Gogs-type forge # Gogs-type forge
elif forge_type in ["gogs", "gitea"]: elif forge_type == "gogs":
if not app_url.endswith('.git'): if not app_url.endswith('.git'):
app_url += ".git" app_url += ".git"