[Backport] Fix MergePullRequest (#278) (#316)

CI.restart()

fix test

Fix MergePullRequest & extend Tests (#278)

rm MergePullRequestResponse

Fix MergePullRequest

Extend Tests

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/278
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/316
Reviewed-by: lafriks <lafriks@noreply.gitea.io>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
6543 2020-04-25 02:36:56 +00:00 committed by Lunny Xiao
parent 4aae4da74d
commit 7eef2b536f
2 changed files with 7 additions and 26 deletions

View File

@ -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

View File

@ -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)
}