Add agentpr pr edit subcommand #15
Reference in New Issue
Block a user
Delete Branch "benvin/agentpr-pr-edit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
agentpr could open a PR and comment on one, but not correct a PR body or title afterwards, so there was no agent-identity path to fix a PR once opened.
pr edit --repo --prwith optional--title/--body, requiring at least oneGiteaClient.EditPRcallingPATCH /repos/{owner}/{repo}/pulls/{index}pr editin README and AGENTSFindings:
internal/agent/gitea.go:219— comment says a pointer to""clears the title. Gitea'sEditPullRequestguards the title withlen(form.Title) > 0(onlyBodyis a*stringthere), so{"title":""}is silently dropped, not applied → fix the comment:Titlecan be set but never cleared; onlyBodycan be blanked.cmd/agentpr/main.go:165—--title ""passes theChanged("title")gate, is sent, is ignored by Gitea, and the command still prints#N <url>as if it succeeded → reject an empty--titlewith an error, the waypr commentrejects an empty--body.internal/agent/client_test.go:155—TestEditPRAPIErrormocks a 422title cannot be empty, which this endpoint never returns; it encodes a wrong belief about the API → use a failure Gitea actually produces (404/403) for the error-surfacing assertion.Findings:
internal/agent/client_test.go:159— the mocked 404 body{"message":"pull request does not exist"}is not a response Gitea produces; a real 404 from this endpoint is{"message":"not found","url":"...","errors":null}(checked against git.unkin.net, Gitea 1.26.2) → mock that body and assert on it, so the test pins the real response shape rather than an invented message.