diff --git a/gitea/pull.go b/gitea/pull.go index 274ecd5..12f7de3 100644 --- a/gitea/pull.go +++ b/gitea/pull.go @@ -153,19 +153,17 @@ type MergePullRequestOption struct { MergeMessageField string `json:"MergeMessageField"` } -// MergePullRequestResponse response when merging a pull request -type MergePullRequestResponse struct { -} - // MergePullRequest merge a PR to repository by PR id -func (c *Client) MergePullRequest(owner, repo string, index int64, opt MergePullRequestOption) (*MergePullRequestResponse, error) { +func (c *Client) MergePullRequest(owner, repo string, index int64, opt MergePullRequestOption) (bool, error) { body, err := json.Marshal(&opt) if err != nil { - return nil, err + return false, err } - response := new(MergePullRequestResponse) - return response, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/pulls/%d/merge", owner, repo, index), - jsonHeader, bytes.NewReader(body), response) + status, err := c.getStatusCode("POST", fmt.Sprintf("/repos/%s/%s/pulls/%d/merge", owner, repo, index), jsonHeader, bytes.NewReader(body)) + if err != nil { + return false, err + } + return status == 200, nil } // IsPullRequestMerged test if one PR is merged to one repository diff --git a/gitea/pull_test.go b/gitea/pull_test.go index 7c391eb..1576b89 100644 --- a/gitea/pull_test.go +++ b/gitea/pull_test.go @@ -31,21 +31,4 @@ func TestPull(t *testing.T) { }) assert.NoError(t, err) assert.Len(t, pulls, 0) - - //ToDo add git stuff to have different branches witch can be used to create PRs and test merge etc ... - - // GetPullRequest get information of one PR - //func (c *Client) GetPullRequest(owner, repo string, index int64) (*PullRequest, error) - - // CreatePullRequest create pull request with options - //func (c *Client) CreatePullRequest(owner, repo string, opt CreatePullRequestOption) (*PullRequest, error) - - // EditPullRequest modify pull request with PR id and options - //func (c *Client) EditPullRequest(owner, repo string, index int64, opt EditPullRequestOption) (*PullRequest, error) - - // MergePullRequest merge a PR to repository by PR id - //func (c *Client) MergePullRequest(owner, repo string, index int64, opt MergePullRequestOption) (*MergePullRequestResponse, error) - - // IsPullRequestMerged test if one PR is merged to one repository - //func (c *Client) IsPullRequestMerged(owner, repo string, index int64) (bool, error) }