Skip to content

Commit

Permalink
fix: add option to accept mr when pipeline succeed
Browse files Browse the repository at this point in the history
  • Loading branch information
ecojuntak committed Sep 29, 2022
1 parent 42cfe20 commit 407ef67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions pkg/gitlab/gitlab_mock/merge_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions pkg/gitlab/merge_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type MergeRequest interface {
CreateToMaster(projectId NameOrId, sourceBranch string, title string) (*gl.MergeRequest, error)
Approve(projectId NameOrId, mergeRequestID int) error
Close(projectId NameOrId, mergeRequestID int) error
Accept(projectId NameOrId, mergeRequestID int, removeBranch bool) (*gl.MergeRequest, error)
Accept(projectId NameOrId, mergeRequestID int, removeBranch bool, whenPipelinePassed bool) (*gl.MergeRequest, error)
}

type mergeRequest struct {
Expand Down Expand Up @@ -94,9 +94,10 @@ func (e *mergeRequest) Close(projectId NameOrId, mergeRequestID int) error {
return err
}

func (e *mergeRequest) Accept(projectId NameOrId, mergeRequestID int, removeBranch bool) (*gl.MergeRequest, error) {
func (e *mergeRequest) Accept(projectId NameOrId, mergeRequestID int, removeBranch bool, whenPipelinePassed bool) (*gl.MergeRequest, error) {
mr, _, err := e.client.MergeRequests.AcceptMergeRequest(projectId.Get(), mergeRequestID, &gl.AcceptMergeRequestOptions{
ShouldRemoveSourceBranch: gl.Bool(removeBranch),
ShouldRemoveSourceBranch: gl.Bool(removeBranch),
MergeWhenPipelineSucceeds: gl.Bool(whenPipelinePassed),
})
if err != nil {
return nil, err
Expand Down

0 comments on commit 407ef67

Please sign in to comment.