Add agentpr pr edit subcommand
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful

Update a PR's title and/or body as the agent user, sending only the
fields supplied.
This commit is contained in:
2026-09-19 12:32:07 +10:00
parent cdced6536e
commit 7bc4082cb0
6 changed files with 171 additions and 8 deletions
+17
View File
@@ -2,6 +2,7 @@ package main
import (
"io"
"strings"
"testing"
)
@@ -16,3 +17,19 @@ func TestExecuteBadRepoErrors(t *testing.T) {
t.Fatal("Execute() = nil, want error for a malformed --repo")
}
}
// `pr edit` with neither --title nor --body has nothing to send; it must fail
// with a usage error before any Vault/Gitea call, so this stays hermetic.
func TestPREditRequiresTitleOrBody(t *testing.T) {
cmd := newRootCmd()
cmd.SetArgs([]string{"pr", "edit", "--repo", "unkin/repo", "--pr", "7"})
cmd.SetOut(io.Discard)
cmd.SetErr(io.Discard)
err := cmd.Execute()
if err == nil {
t.Fatal("Execute() = nil, want an error when neither --title nor --body is given")
}
if !strings.Contains(err.Error(), "--title or --body") {
t.Errorf("error = %q, want it to name the missing flags", err)
}
}