Add agentpr pr edit subcommand
Update a PR's title and/or body as the agent user, sending only the fields supplied.
This commit is contained in:
@@ -214,6 +214,22 @@ func (c *GiteaClient) CreatePR(repoPath string, opts CreatePROptions) (PullReque
|
||||
return pr, err
|
||||
}
|
||||
|
||||
// EditPROptions are the fields an edit may change. Pointers so an unset field
|
||||
// is omitted from the payload entirely: Gitea overwrites whatever it is sent,
|
||||
// so a nil Title leaves the title alone while a pointer to "" clears it.
|
||||
type EditPROptions struct {
|
||||
Title *string `json:"title,omitempty"`
|
||||
Body *string `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// EditPR updates a pull request's title and/or body
|
||||
// (PATCH /api/v1/repos/{owner}/{repo}/pulls/{index}).
|
||||
func (c *GiteaClient) EditPR(repoPath string, number int, opts EditPROptions) (PullRequest, error) {
|
||||
var pr PullRequest
|
||||
err := c.do(http.MethodPatch, fmt.Sprintf("/api/v1/repos/%s/pulls/%d", repoPath, number), opts, &pr)
|
||||
return pr, err
|
||||
}
|
||||
|
||||
// GetPR fetches a single pull request.
|
||||
func (c *GiteaClient) GetPR(repoPath string, number int) (PullRequest, error) {
|
||||
var pr PullRequest
|
||||
|
||||
Reference in New Issue
Block a user