update MergePullRequest (#207)
update license header code format enforce enum Fix #137 Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Thomas Loubiou <xabufr@gmail.com> Reviewed-by: Andrew Thornton <art27@cantab.net> Reviewed-by: mrsdizzie <info@mrsdizzie.com>
This commit is contained in:
parent
f971aa81f4
commit
c7686bd633
1 changed files with 22 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
||||||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||||
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a MIT-style
|
// Use of this source code is governed by a MIT-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
@ -124,10 +125,28 @@ func (c *Client) EditPullRequest(owner, repo string, index int64, opt EditPullRe
|
||||||
jsonHeader, bytes.NewReader(body), pr)
|
jsonHeader, bytes.NewReader(body), pr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MergePullRequestOption options when merging a pull request
|
||||||
|
type MergePullRequestOption struct {
|
||||||
|
// required: true
|
||||||
|
// enum: merge,rebase,rebase-merge,squash
|
||||||
|
Do string `json:"Do" binding:"Required;In(merge,rebase,rebase-merge,squash)"`
|
||||||
|
MergeTitleField string `json:"MergeTitleField"`
|
||||||
|
MergeMessageField string `json:"MergeMessageField"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MergePullRequestResponse response when merging a pull request
|
||||||
|
type MergePullRequestResponse struct {
|
||||||
|
}
|
||||||
|
|
||||||
// MergePullRequest merge a PR to repository by PR id
|
// MergePullRequest merge a PR to repository by PR id
|
||||||
func (c *Client) MergePullRequest(owner, repo string, index int64) error {
|
func (c *Client) MergePullRequest(owner, repo string, index int64, opt MergePullRequestOption) (*MergePullRequestResponse, error) {
|
||||||
_, err := c.getResponse("POST", fmt.Sprintf("/repos/%s/%s/pulls/%d/merge", owner, repo, index), nil, nil)
|
body, err := json.Marshal(&opt)
|
||||||
return err
|
if err != nil {
|
||||||
|
return nil, 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsPullRequestMerged test if one PR is merged to one repository
|
// IsPullRequestMerged test if one PR is merged to one repository
|
||||||
|
|
Loading…
Reference in a new issue