Milestones and review in the new loop (M2.1, PR C)
CI / checks (push) Skipped
CI / checks (pull_request) Successful in 1m48s
CI / checks (push) Skipped
CI / checks (pull_request) Successful in 1m48s
A work item starts from a fresh workspace: fetch, set aside (never discard) leftover changes, branches and unpushed commits, a clean default branch, and a branch of its own (D3, #62). start_milestone cuts the milestone's branch; finish_milestone commits only the work, pushes and opens a PR that closes the issue, under an intent, adopting an open PR and treating a closed one as the operator's answer (D4). Between runs the loop watches each item's PR: operator comments and inline review notes (#69) reach the item, a merge or close hands back to the driver. A review fix is checked after it's pushed and goes out as a new PR if the PR merged first (D5). At boot an interrupted publish is settled against Gitea (L8). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
This commit is contained in:
1 parent
f84bb70839
commit
21744efac1
9 files changed
+1004
-10
No files matched your search
@@ -32,6 +32,18 @@ class PullRequest:
|
||||
state: str
|
||||
head: str
|
||||
url: str
|
||||
merged: bool = False
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ReviewNote:
|
||||
"""Something a reviewer said in a review: its body, or a comment on a
|
||||
line (#69). ``key`` is unique across both kinds."""
|
||||
|
||||
key: str
|
||||
author: str
|
||||
body: str
|
||||
where: str # "path:line" for a line comment, "" for a review body
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -100,6 +112,40 @@ class GiteaClient:
|
||||
)
|
||||
return _pull_request(data)
|
||||
|
||||
def pull_request(self, repo: str, index: int) -> PullRequest:
|
||||
return _pull_request(self._request("GET", f"/repos/{repo}/pulls/{index}"))
|
||||
|
||||
def review_notes(self, repo: str, index: int) -> list[ReviewNote]:
|
||||
"""Review bodies and inline line comments on a PR (#69): the PR's
|
||||
conversation comments come from list_comments."""
|
||||
notes: list[ReviewNote] = []
|
||||
for review in (
|
||||
self._request("GET", f"/repos/{repo}/pulls/{index}/reviews") or []
|
||||
):
|
||||
author = (review.get("user") or {}).get("login", "")
|
||||
body = str(review.get("body") or "").strip()
|
||||
if body:
|
||||
notes.append(ReviewNote(f"review-{review['id']}", author, body, ""))
|
||||
if not review.get("comments_count"):
|
||||
continue
|
||||
for comment in (
|
||||
self._request(
|
||||
"GET",
|
||||
f"/repos/{repo}/pulls/{index}/reviews/{review['id']}/comments",
|
||||
)
|
||||
or []
|
||||
):
|
||||
line = comment.get("line") or comment.get("position") or ""
|
||||
notes.append(
|
||||
ReviewNote(
|
||||
key=f"line-{comment['id']}",
|
||||
author=(comment.get("user") or {}).get("login", author),
|
||||
body=str(comment.get("body") or ""),
|
||||
where=f"{comment.get('path', '')}:{line}",
|
||||
)
|
||||
)
|
||||
return notes
|
||||
|
||||
def find_pull_request(self, repo: str, head: str) -> PullRequest | None:
|
||||
"""External truth for L8: did the PR for this branch already get
|
||||
opened? Includes closed PRs — a crash after opening must not be
|
||||
@@ -220,6 +266,7 @@ def _pull_request(data: dict[str, Any]) -> PullRequest:
|
||||
state=data.get("state", ""),
|
||||
head=(data.get("head") or {}).get("ref", ""),
|
||||
url=data.get("html_url", ""),
|
||||
merged=bool(data.get("merged")),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user