nisse-review: a commit diff Gitea can't give falls back to the whole diff
From nisse-review's review of #156: only a failed listing fell back to the PR's whole diff; one commit's diff failing (a force-push dropped it) failed the run. Tests also pin down its other three points, which the code already handled: a command is taken in once, a second review at the same head has its own marker, and `review` beside a comment is one fresh review. 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
fca4c41d95
commit
e107484042
2 files changed
+60
-7
No files matched your search
@@ -384,23 +384,24 @@ class Reviewer:
|
||||
|
||||
def _changes(self, repo: str, pr: PullRequest, since: str) -> str:
|
||||
"""The commits since ``since``, each with its diff; the whole PR's
|
||||
diff if Gitea can't list them (``since`` gone, say)."""
|
||||
diff if Gitea can't list them or give one's diff (``since`` gone
|
||||
after a force-push, say)."""
|
||||
try:
|
||||
commits = self._gitea.commits_between(repo, since, pr.head_sha)
|
||||
diffs = "\n".join(
|
||||
f"commit {line}\n{self._gitea.commit_diff(repo, line.split()[0])}"
|
||||
for line in commits
|
||||
)
|
||||
except GiteaError as exc:
|
||||
self._oplog.emit("review.compare_failed", cause=str(exc)[:300])
|
||||
commits = []
|
||||
if not commits:
|
||||
return (
|
||||
"Gitea couldn't list the commits since then (a force-push?): "
|
||||
"Gitea couldn't give the commits since then (a force-push?): "
|
||||
"the whole PR's diff instead.\n"
|
||||
+ self._cut(self._gitea.pull_request_diff(repo, pr.number))
|
||||
+ "\n\n"
|
||||
)
|
||||
diffs = "\n".join(
|
||||
f"commit {line}\n{self._gitea.commit_diff(repo, line.split()[0])}"
|
||||
for line in commits
|
||||
)
|
||||
return (
|
||||
"The commits since:\n"
|
||||
+ "\n".join(commits)
|
||||
|
||||
Reference in new issue
Block a user