Add --base to agentpr pr edit to retarget a PR
This commit is contained in:
@@ -102,7 +102,7 @@ func TestCreatePRRequestBody(t *testing.T) {
|
||||
// An edit must send only the fields it was given: Gitea overwrites whatever
|
||||
// key it receives, so an omitted --title arriving as "" would blank the title.
|
||||
func TestEditPRSendsOnlySuppliedFields(t *testing.T) {
|
||||
title, body, empty := "new title", "new body", ""
|
||||
title, body, base, empty := "new title", "new body", "benvin/parent", ""
|
||||
tests := []struct {
|
||||
name string
|
||||
opts EditOptions
|
||||
@@ -112,6 +112,8 @@ func TestEditPRSendsOnlySuppliedFields(t *testing.T) {
|
||||
{"title only", EditOptions{Title: &title}, map[string]any{"title": "new title"}},
|
||||
{"both", EditOptions{Title: &title, Body: &body}, map[string]any{"title": "new title", "body": "new body"}},
|
||||
{"explicit empty body is sent", EditOptions{Body: &empty}, map[string]any{"body": ""}},
|
||||
{"base only", EditOptions{Base: &base}, map[string]any{"base": "benvin/parent"}},
|
||||
{"base with title", EditOptions{Title: &title, Base: &base}, map[string]any{"title": "new title", "base": "benvin/parent"}},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
@@ -283,13 +283,15 @@ func (c *GiteaClient) CreatePR(repoPath string, opts CreatePROptions) (PullReque
|
||||
// entirely, leaving that field as it is. The two fields are not symmetric:
|
||||
// Gitea only applies a title when it is non-empty, so Title can be set but
|
||||
// never cleared and a "" title is a silent no-op, while a pointer to "" Body
|
||||
// really does blank the body.
|
||||
// really does blank the body. Base retargets a pull request and is never set
|
||||
// for an issue.
|
||||
type EditOptions struct {
|
||||
Title *string `json:"title,omitempty"`
|
||||
Body *string `json:"body,omitempty"`
|
||||
Base *string `json:"base,omitempty"`
|
||||
}
|
||||
|
||||
// EditPR updates a pull request's title and/or body
|
||||
// EditPR updates a pull request's title, body and/or base branch
|
||||
// (PATCH /api/v1/repos/{owner}/{repo}/pulls/{index}).
|
||||
func (c *GiteaClient) EditPR(repoPath string, number int, opts EditOptions) (PullRequest, error) {
|
||||
var pr PullRequest
|
||||
|
||||
Reference in New Issue
Block a user