Add .diff and .patch endpoints for pull requests (#398)

Add .diff and .patch endpoints for pull requests

fixes #364

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>

Co-authored-by: Andrew Bayer <andrew.bayer@gmail.com>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/398
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: 6543 <6543@noreply.gitea.io>
This commit is contained in:
abayer 2020-09-04 19:21:05 +00:00 committed by 6543
parent 9e280adb4d
commit c2f232c130

View file

@ -220,3 +220,13 @@ func (c *Client) IsPullRequestMerged(owner, repo string, index int64) (bool, err
return statusCode == 204, nil return statusCode == 204, nil
} }
// GetPullRequestPatch gets the .patch file as bytes for a PR
func (c *Client) GetPullRequestPatch(owner, repo string, index int64) ([]byte, error) {
return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/pulls/%d.patch", owner, repo, index), nil, nil)
}
// GetPullRequestDiff gets the .diff file as bytes for a PR
func (c *Client) GetPullRequestDiff(owner, repo string, index int64) ([]byte, error) {
return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/pulls/%d.diff", owner, repo, index), nil, nil)
}