feat(tools): pr_merge

This commit is contained in:
Mathias Bergqvist
2026-05-06 22:48:02 +02:00
parent 388131c8cd
commit 284d5e19f6
4 changed files with 199 additions and 0 deletions

View File

@@ -103,6 +103,25 @@ func (c *Client) GetPullRequestDiff(ctx context.Context, owner, repo string, ind
return resp.Body, nil
}
type MergePRArgs struct {
Do string `json:"Do"`
Title string `json:"merge_message_title,omitempty"`
Body string `json:"merge_message_field,omitempty"`
}
func (c *Client) MergePullRequest(ctx context.Context, owner, repo string, index int, args MergePRArgs) error {
p := fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/merge", owner, repo, index)
payload, err := json.Marshal(args)
if err != nil {
return err
}
body, status, err := c.PostJSON(ctx, p, payload)
if err != nil {
return err
}
return MapStatus(status, body)
}
func (c *Client) ListPullRequests(ctx context.Context, owner, repo, state, head string, page, limit int) ([]PullRequest, error) {
if page < 1 {
page = 1