fix(scripts): resolve Gitea label names to IDs in issue filer
Some checks failed
CI / lint (push) Successful in 34s
Deploy / notebooks (push) Has been skipped
Deploy / zotero (push) Has been skipped
Deploy / docs (push) Has been skipped
Deploy / api (push) Has been skipped
Deploy / mc (push) Has been skipped
Deploy / report (push) Successful in 17s
CI / test (push) Failing after 13m7s
Some checks failed
CI / lint (push) Successful in 34s
Deploy / notebooks (push) Has been skipped
Deploy / zotero (push) Has been skipped
Deploy / docs (push) Has been skipped
Deploy / api (push) Has been skipped
Deploy / mc (push) Has been skipped
Deploy / report (push) Successful in 17s
CI / test (push) Failing after 13m7s
Gitea's create-issue API takes label IDs, not names, so the filer would have dropped/errored on string labels. Resolve names against the repo's labels and include only those that exist. Used to file the concurrency issues #508-#514.
This commit is contained in:
@@ -188,12 +188,20 @@ def main() -> None:
|
|||||||
|
|
||||||
client = GiteaClient(token, base_url=args.base_url)
|
client = GiteaClient(token, base_url=args.base_url)
|
||||||
try:
|
try:
|
||||||
|
# Gitea wants label IDs, not names — resolve against the repo's
|
||||||
|
# labels and silently drop any that don't exist.
|
||||||
|
existing = {
|
||||||
|
lab["name"]: lab["id"]
|
||||||
|
for lab in client.get(
|
||||||
|
f"/repos/{OWNER}/{REPO}/labels", params={"limit": 100}
|
||||||
|
).json()
|
||||||
|
}
|
||||||
for i in issues:
|
for i in issues:
|
||||||
res = client.create_issue(
|
body = {"title": i["title"], "body": i["body"]}
|
||||||
OWNER,
|
ids = [existing[n] for n in i["labels"] if n in existing]
|
||||||
REPO,
|
if ids:
|
||||||
{"title": i["title"], "body": i["body"], "labels": i["labels"]},
|
body["labels"] = ids
|
||||||
)
|
res = client.create_issue(OWNER, REPO, body)
|
||||||
print(
|
print(
|
||||||
f"filed #{res.get('number')} {i['title']}\n {res.get('html_url', '')}"
|
f"filed #{res.get('number')} {i['title']}\n {res.get('html_url', '')}"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user