nisse-review: later reviews, replies, rounds, stop and review (M7.5)
Back on a PR it reviewed: a new head gets a later review of the commits since (each one's diff, through the API) and of its earlier points; what was said since gets replies, answered where it was said or skipped with a reason. It signs off once and stays quiet while still happy. Past tuning.review.max_rounds it sums up for the operator and goes quiet, until a push or someone other than the PR's author joins in. An operator's `stop` quiets it; `review` asks for a fresh review. Reviews carry numbered markers and replies their point's key, so recovery posts nothing twice. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J5Utyfzw7gF7UhjRDEtjTk
This commit is contained in:
1 parent
7e73b8fb37
commit
37bbac7e72
14 files changed
+1268
-157
No files matched your search
@@ -520,6 +520,33 @@ class GiteaClient:
|
||||
)
|
||||
return int(data["id"])
|
||||
|
||||
def commits_between(self, repo: str, base: str, head: str) -> list[str]:
|
||||
"""The commits from ``base`` to ``head`` ("sha subject"), oldest
|
||||
first. After a force-push that drops ``base``, Gitea counts from the
|
||||
two heads' merge base."""
|
||||
data = self._request("GET", f"/repos/{repo}/compare/{base}...{head}") or {}
|
||||
found: list[str] = []
|
||||
for commit in data.get("commits") or []:
|
||||
message = str((commit.get("commit") or {}).get("message") or "")
|
||||
subject = message.splitlines()[0] if message.strip() else ""
|
||||
found.append(f"{commit['sha']} {subject}".rstrip())
|
||||
return found[::-1] # Gitea lists the newest first
|
||||
|
||||
def commit_diff(self, repo: str, sha: str) -> str:
|
||||
"""One commit's diff. Through the API, so a token reads private
|
||||
repositories (the web's compare diff doesn't take one)."""
|
||||
return self._raw(f"/repos/{repo}/git/commits/{sha}.diff").decode(
|
||||
errors="replace"
|
||||
)
|
||||
|
||||
def react(self, repo: str, comment_id: int, content: str) -> None:
|
||||
"""A reaction (``+1``, ``eyes``, ...) on a PR's or issue's comment."""
|
||||
self._request(
|
||||
"POST",
|
||||
f"/repos/{repo}/issues/comments/{comment_id}/reactions",
|
||||
json={"content": content},
|
||||
)
|
||||
|
||||
def close(self) -> None:
|
||||
self._http.close()
|
||||
|
||||
|
||||
@@ -418,3 +418,30 @@ def test_a_pull_request_carries_what_a_review_needs() -> None:
|
||||
True,
|
||||
)
|
||||
assert gitea.pull_request_diff("o/r", 7) == "diff --git a/x b/x\n"
|
||||
|
||||
|
||||
def test_commits_between_are_oldest_first_and_diffs_come_through_the_api() -> None:
|
||||
# Gitea lists the newest first; its web compare diff takes no token.
|
||||
seen: list[tuple[str, str, bytes]] = []
|
||||
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
seen.append((request.method, request.url.path, request.content))
|
||||
if "/compare/" in request.url.path:
|
||||
commits = [
|
||||
{"sha": "c2", "commit": {"message": "Second\n\nbody"}},
|
||||
{"sha": "c1", "commit": {"message": "First"}},
|
||||
]
|
||||
return httpx.Response(200, json={"total_commits": 2, "commits": commits})
|
||||
if request.url.path.endswith(".diff"):
|
||||
return httpx.Response(200, text="diff --git a/x b/x\n")
|
||||
return httpx.Response(201, json={"content": "+1"})
|
||||
|
||||
gitea = client(handler)
|
||||
assert gitea.commits_between("o/r", "a1", "c2") == ["c1 First", "c2 Second"]
|
||||
assert gitea.commit_diff("o/r", "c1").startswith("diff --git")
|
||||
gitea.react("o/r", 42, "+1")
|
||||
assert seen[0][1] == "/api/v1/repos/o/r/compare/a1...c2"
|
||||
assert seen[1][1] == "/api/v1/repos/o/r/git/commits/c1.diff"
|
||||
method, path, body = seen[2]
|
||||
assert (method, path) == ("POST", "/api/v1/repos/o/r/issues/comments/42/reactions")
|
||||
assert json.loads(body) == {"content": "+1"}
|
||||
Reference in new issue
Block a user