Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Lassie

> :dog: Lassie loves :hotdog: `s and her doghouse is in the garden of Gitlab,
but as a Rough Collie she has more to offer:
> but as a Rough Collie she has more to offer:

- She can check your progress on Merge-Requests, merge them and hand out treats for diligent contributors
- More to come ...
Expand Down Expand Up @@ -53,13 +53,30 @@ helm delete my-lassie-bot-dog

Lassie can be controlled with a config file. To enable lassie for a project you have to create this file called `lassie.json` at the top-level of the repository.

```json5
```json
{
"$schema": "https://geprog.github.io/lassie-bot-dog/lassie.schema.json",
"plugins": {
"auto_merge": {
"squash": true,
"neededLabels": ["👀 Ready for Review"]
"neededLabels": ["👀 Ready for Review"],
"neededApprovals": [
{
"label": "*",
"users": ["maintainer", "maintainer-2"],
"atLeast": 1
}
],
// "ignoredChecks": [
// "has-assignee",
// "has-labels",
// "passes-ci",
// "is-title-using-conventional-commit",
// "is-not-work-in-progress",
// "has-no-open-discussions",
// "has-conflicts",
// "has-enough-approvals"
// ]
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions config/lassie.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@
},
"minItems": 1,
"uniqueItems": true
},
"ignoredChecks": {
"description": "Checks that are ignored when auto merging",
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
}
}
}
Expand Down
1 change: 1 addition & 0 deletions plugins/auto_merge/config/auto_merge_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ type AutoMergeConfig struct {
Squash bool `json:"squash"`
NeededLabels []string `json:"neededLabels"`
NeededApprovals []NeededApproval `json:"neededApprovals"`
IgnoredChecks []string `json:"ignoredChecks"`
}
24 changes: 17 additions & 7 deletions plugins/auto_merge/merge_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package auto_merge
import (
"github.com/GEPROG/lassie-bot-dog/plugins/auto_merge/checks"
"github.com/GEPROG/lassie-bot-dog/plugins/auto_merge/config"
"github.com/GEPROG/lassie-bot-dog/utils"
"github.com/xanzy/go-gitlab"
)

Expand Down Expand Up @@ -30,7 +31,7 @@ type mergeStatus struct {

func (plugin AutoMergePlugin) checkMergeRequest(project *gitlab.Project, mergeRequest *gitlab.MergeRequest) *mergeStatus {
// TODO: find better place to load this
plugin.setupMergeChecks()
plugin.setupMergeChecks(plugin.loadedConfig)

status := &mergeStatus{
mergeRequestID: mergeRequest.ID,
Expand All @@ -57,12 +58,8 @@ func (plugin AutoMergePlugin) checkMergeRequest(project *gitlab.Project, mergeRe
return status
}

func (plugin AutoMergePlugin) setupMergeChecks() {
if mergeChecks != nil {
return
}

mergeChecks = []mergeCheck{
func (plugin AutoMergePlugin) setupMergeChecks(config *config.AutoMergeConfig) {
allMergeChecks := []mergeCheck{
checks.HasEnoughApprovalsCheck{
Client: plugin.Client,
},
Expand All @@ -76,4 +73,17 @@ func (plugin AutoMergePlugin) setupMergeChecks() {
},
checks.IsTitleUsingConventionalCommit{},
}

if config.IgnoredChecks != nil {
// filter out ignored checks
var _mergeChecks []mergeCheck
for _, check := range allMergeChecks {
if utils.StringInSlice(check.Name(), config.IgnoredChecks) {
mergeChecks = append(mergeChecks, check)
}
}
mergeChecks = _mergeChecks
} else {
mergeChecks = allMergeChecks
Comment on lines +85 to +87
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this works with the global variable 🤔

}
}