fix(gitea): check labels before creating, Gitea allows duplicates

This commit is contained in:
hh
2026-09-10 16:07:02 +00:00
parent d7e948df33
commit 2785443794
+6 -6
View File
@@ -156,16 +156,16 @@ def gitea(args: argparse.Namespace) -> None:
raw = response.read()
return json.loads(raw) if raw else None
# Gitea happily creates a second label with the same name, so the only way to
# stay idempotent is to look first.
existing = {label["name"] for label in call("GET", f"/repos/{args.repo}/labels?limit=100") or []}
for name, color, description in RENOVATE_LABELS:
try:
if name in existing:
print(f"label {name}: already there")
continue
call("POST", f"/repos/{args.repo}/labels",
{"name": name, "color": color, "description": description})
print(f"label {name}: created")
except urllib.error.HTTPError as error:
if error.code in (409, 422):
print(f"label {name}: already there")
else:
sys.exit(f"label {name}: {error.code} {error.read()[:200]!r}")
try:
call("GET", f"/repos/{args.repo}/contents/{RENOVATE_FILE}")