From ba6f41a16e1489899fe95f27129c7c7fd876d816 Mon Sep 17 00:00:00 2001 From: domverse Date: Fri, 14 Aug 2026 12:27:41 +0200 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01WMctdE9E1c8d6UHQWX8rNt --- work_item/src/work_item/core.py | 29 +++++++++++++++++------------ work_item/tests/test_cli_e2e.py | 7 +++++++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/work_item/src/work_item/core.py b/work_item/src/work_item/core.py index 4c755e2..c7a2334 100644 --- a/work_item/src/work_item/core.py +++ b/work_item/src/work_item/core.py @@ -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) diff --git a/work_item/tests/test_cli_e2e.py b/work_item/tests/test_cli_e2e.py index 3f4c566..f2892b7 100644 --- a/work_item/tests/test_cli_e2e.py +++ b/work_item/tests/test_cli_e2e.py @@ -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"]: