commit: 2b800f75c8213aa5faa12b518a3792092bf60728
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 14 10:58:04 2026 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Feb 14 10:58:04 2026 +0000
URL:
https://gitweb.gentoo.org/proj/repo-mirror-ci.git/commit/?id=2b800f75
pull-request: Post codeberg CI results as comments
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
pull-request/codebergapi.py | 14 ++++++--------
pull-request/report-pull-request.py | 10 +++++-----
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/pull-request/codebergapi.py b/pull-request/codebergapi.py
index 1c99034..3c591e4 100644
--- a/pull-request/codebergapi.py
+++ b/pull-request/codebergapi.py
@@ -89,21 +89,19 @@ class CodebergAPI:
def files(self, pr_id: int) -> list[dict]:
return
self.session.get(f"{self.repos_baseurl}/pulls/{pr_id}/files").json()
- def get_reviews(self, pr_id: int) -> list[dict]:
- return
self.session.get(f"{self.repos_baseurl}/pulls/{pr_id}/reviews").json()
+ def get_comments(self, pr_id: int) -> list[dict]:
+ return
self._get_paginated(f"{self.repos_baseurl}/issues/{pr_id}/comments")
- def create_review(self, pr_id: int, comment: str) -> None:
- # Does not appear to be possible to simply post comments
- # https://codeberg.org/api/swagger#/repository/repoCreatePullReview
+ def create_comment(self, pr_id: int, comment: str) -> None:
self.session.post(
- f"{self.repos_baseurl}/pulls/{pr_id}/reviews",
+ f"{self.repos_baseurl}/issues/{pr_id}/comments",
json={
"body": comment,
},
)
- def delete_review(self, pr_id: int, review_id: int) -> None:
-
self.session.delete(f"{self.repos_baseurl}/pulls/{pr_id}/reviews/{review_id}")
+ def delete_comment(self, comment_id: int) -> None:
+
self.session.delete(f"{self.repos_baseurl}/issues/comments/{comment_id}")
def teams(self, org: str) -> Generator[None, dict, None]:
# https://codeberg.org/api/swagger#/organization/orgListTeams
diff --git a/pull-request/report-pull-request.py
b/pull-request/report-pull-request.py
index 2b700be..7e3b7ed 100755
--- a/pull-request/report-pull-request.py
+++ b/pull-request/report-pull-request.py
@@ -33,18 +33,18 @@ def report_codeberg_pr(
had_broken = False
old_comments = []
# note: technically we could have multiple leftover comments
- for co in cb.get_reviews(prid):
+ for co in cb.get_comments(prid):
if co["user"]["login"] == CODEBERG_USERNAME:
# skip comments that don't look like CI results
if not co["body"].startswith("## Pull request CI report"):
continue
- old_comments.append(co)
+ old_comments.append(co["id"])
had_broken = had_broken or any(
sub in co["body"] for sub in HAD_BROKEN_SUBS
)
- for co in old_comments:
- cb.delete_review(prid, co["id"])
+ for co_id in old_comments:
+ cb.delete_comment(co_id)
report_url = report_uri_prefix + "/" + prhash + "/output.html"
body = f"""## Pull request CI report
@@ -69,7 +69,7 @@ def report_codeberg_pr(
else:
body += "\nNo issues found\n"
- cb.create_review(prid, body)
+ cb.create_comment(prid, body)
if borked:
cb.commit_set_status(