From c2f232c130777602bb59d3474c682d9105d5a88f Mon Sep 17 00:00:00 2001 From: abayer Date: Fri, 4 Sep 2020 19:21:05 +0000 Subject: [PATCH] Add .diff and .patch endpoints for pull requests (#398) Add .diff and .patch endpoints for pull requests fixes #364 Signed-off-by: Andrew Bayer Co-authored-by: Andrew Bayer Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/398 Reviewed-by: techknowlogick Reviewed-by: 6543 <6543@noreply.gitea.io> --- gitea/pull.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gitea/pull.go b/gitea/pull.go index d1659dc..ce85cb0 100644 --- a/gitea/pull.go +++ b/gitea/pull.go @@ -220,3 +220,13 @@ func (c *Client) IsPullRequestMerged(owner, repo string, index int64) (bool, err 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) +}