Skip to content

Commit

Permalink
check: add draft option on ressource
Browse files Browse the repository at this point in the history
WIP is deprecated, use DRAFT instead

Signed-off-by: Jonathan  Monnet <jmonnet@baylibre.com>
  • Loading branch information
Baylibrejmonnet committed May 7, 2022
1 parent a362ed8 commit 20f9978
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ resources:
* `uri`: (required) The location of the repository (required)
* `private_token`: (required) Your GitLab user's private token (required, can be found in your profile settings)
* `insecure`: When set to `true`, SSL verification is turned off
* `skip_draft`: when set to `true`merge requests mark as draft will be skipped Default `false`
* `skip_work_in_progress`: When set to `true`, merge requests mark as work in progress (WIP) will be skipped. Default `false`
* `skip_not_mergeable`: When set to `true`, merge requests not marked as mergeable will be skipped. Default `false`
* `skip_trigger_comment`: When set to `true`, the resource will not look up for `[trigger ci]` merge request comments to manually trigger builds. Default `false`
Expand Down
9 changes: 7 additions & 2 deletions pkg/check/command.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package check

import (
"github.com/DrummyFloyd/gitlab-merge-request-resource/pkg"
"github.com/xanzy/go-gitlab"
"strings"
"time"

"github.com/DrummyFloyd/gitlab-merge-request-resource/pkg"
"github.com/xanzy/go-gitlab"
)

type Command struct {
Expand Down Expand Up @@ -63,6 +64,10 @@ func (command *Command) Run(request Request) (Response, error) {
updatedAt = getMostRecentUpdateTime(notes, updatedAt)
}

if request.Source.SkipDrafts && mr.Draft {
continue
}

if request.Source.SkipNotMergeable && mr.MergeStatus != "can_be_merged" {
continue
}
Expand Down
1 change: 1 addition & 0 deletions pkg/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Source struct {
PrivateToken string `json:"private_token"`
Insecure bool `json:"insecure"`
SkipWorkInProgress bool `json:"skip_work_in_progress,omitempty"`
SkipDrafts bool `json:"skip_drafts,omitempty"`
SkipNotMergeable bool `json:"skip_not_mergeable,omitempty"`
SkipTriggerComment bool `json:"skip_trigger_comment,omitempty"`
ConcourseUrl string `json:"concourse_url,omitempty"`
Expand Down

0 comments on commit 20f9978

Please sign in to comment.