From 4c4479d4eab7c2fd3ead1b4299aae604f2cf6e31 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Thu, 25 Aug 2022 16:46:06 +0800 Subject: [PATCH] gitea: omit default branch if not specified, fix for blm --- nvchecker_source/gitea.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nvchecker_source/gitea.py b/nvchecker_source/gitea.py index 0ff3a93..50da908 100644 --- a/nvchecker_source/gitea.py +++ b/nvchecker_source/gitea.py @@ -5,7 +5,7 @@ from __future__ import annotations import urllib.parse -GITEA_URL = 'https://%s/api/v1/repos/%s/commits?sha=%s' +GITEA_URL = 'https://%s/api/v1/repos/%s/commits' GITEA_MAX_TAG = 'https://%s/api/v1/repos/%s/tags' from nvchecker.api import ( @@ -17,14 +17,16 @@ async def get_version( cache: AsyncCache, keymanager: KeyManager, ) -> VersionResult: repo = urllib.parse.quote(conf['gitea']) - br = conf.get('branch', 'master') + br = conf.get('branch') host = conf.get('host', 'gitea.com') use_max_tag = conf.get('use_max_tag', False) if use_max_tag: url = GITEA_MAX_TAG % (host, repo) else: - url = GITEA_URL % (host, repo, br) + url = GITEA_URL % (host, repo) + if br: + url += '?sha=' + br # Load token from config token = conf.get('token')