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:
@@ -446,19 +446,24 @@ class Gitea:
|
|||||||
self.tea(*args)
|
self.tea(*args)
|
||||||
|
|
||||||
def claim(self, story: Story) -> None:
|
def claim(self, story: Story) -> None:
|
||||||
self.tea(
|
self.edit_labels(
|
||||||
"issues",
|
story.number,
|
||||||
"edit",
|
add=("status/in-progress",),
|
||||||
str(story.number),
|
remove=(
|
||||||
"--repo",
|
"status/backlog",
|
||||||
self.config.repo_slug,
|
"status/ready",
|
||||||
"--add-assignees",
|
"status/blocked",
|
||||||
self.config.assignee,
|
"status/review",
|
||||||
"--add-labels",
|
"status/done",
|
||||||
"status/in-progress",
|
),
|
||||||
"--remove-labels",
|
|
||||||
"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:
|
def comment(self, issue: int, body: str) -> None:
|
||||||
self.tea("comments", "add", str(issue), body, "--repo", self.config.repo_slug)
|
self.tea("comments", "add", str(issue), body, "--repo", self.config.repo_slug)
|
||||||
|
|||||||
@@ -50,6 +50,13 @@ if args[0] == "api":
|
|||||||
out(state["prs"][str(number)])
|
out(state["prs"][str(number)])
|
||||||
elif "/commits/" in endpoint and endpoint.endswith("/status"):
|
elif "/commits/" in endpoint and endpoint.endswith("/status"):
|
||||||
out({"state": state.get("ci_state", "success")})
|
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:
|
else:
|
||||||
raise SystemExit(f"unsupported api: {endpoint}")
|
raise SystemExit(f"unsupported api: {endpoint}")
|
||||||
elif args[:2] == ["issues", "edit"]:
|
elif args[:2] == ["issues", "edit"]:
|
||||||
|
|||||||
Reference in New Issue
Block a user