fix(work-item): assign issues via PATCH instead of broken sub-route

`tea --add-assignees` posts to /issues/{n}/assignees, which returns 404 on
this Forgejo deployment and makes every `claim` fail. Set the assignee through
the issue PATCH endpoint (full assignees list), which the server accepts, and
reuse `edit_labels` for the status transition. Update the CLI e2e fake `tea`
to model the PATCH assignee call.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WMctdE9E1c8d6UHQWX8rNt
This commit is contained in:
2026-08-14 12:27:41 +02:00
parent b59bc93fcb
commit ba6f41a16e
2 changed files with 24 additions and 12 deletions

View File

@@ -446,19 +446,24 @@ class Gitea:
self.tea(*args)
def claim(self, story: Story) -> None:
self.tea(
"issues",
"edit",
str(story.number),
"--repo",
self.config.repo_slug,
"--add-assignees",
self.config.assignee,
"--add-labels",
"status/in-progress",
"--remove-labels",
"status/backlog,status/ready,status/blocked,status/review,status/done",
self.edit_labels(
story.number,
add=("status/in-progress",),
remove=(
"status/backlog",
"status/ready",
"status/blocked",
"status/review",
"status/done",
),
)
self.set_assignee(story.number, self.config.assignee)
def set_assignee(self, issue: int, assignee: str) -> None:
# Some Gitea/Forgejo deployments 404 on the issues/{n}/assignees
# sub-route that `tea --add-assignees` uses; the issue PATCH endpoint
# accepts the full assignees list and works across those versions.
self.api(f"{self.base}/issues/{issue}", method="PATCH", data={"assignees": [assignee]})
def comment(self, issue: int, body: str) -> None:
self.tea("comments", "add", str(issue), body, "--repo", self.config.repo_slug)

View File

@@ -50,6 +50,13 @@ if args[0] == "api":
out(state["prs"][str(number)])
elif "/commits/" in endpoint and endpoint.endswith("/status"):
out({"state": state.get("ci_state", "success")})
elif "--method" in args and args[args.index("--method") + 1] == "PATCH" and "/issues/" in endpoint:
number = int(endpoint.rsplit("/", 1)[1])
issue = next(x for x in state["issues"] if x["number"] == number)
payload = json.loads(args[args.index("--data") + 1])
if "assignees" in payload:
issue["assignees"] = [{"login": login} for login in payload["assignees"]]
save(); out(issue)
else:
raise SystemExit(f"unsupported api: {endpoint}")
elif args[:2] == ["issues", "edit"]: