Skip to content
Merged
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- rule for approvals
- rule for approvers
- merge on command
- update branch


### Commands
Expand Down Expand Up @@ -55,6 +56,8 @@ Config file must be named `.mrbot.yaml` and placed in root directory

- `title_regex`: pattern of title, default is `.*`

- `greetings_enabled`: enable message for new MR, default is `false`

- `greetings_template`: template of message for new MR, default is `Requirements:\n - Min approvals: {{ .MinApprovals }}\n - Title regex: {{ .TitleRegex }}\n\nOnce you've done, send **!merge** command and i will merge it!`

- `auto_master_merge`: the bot tries to merge target branch, default is `false`
Expand All @@ -70,6 +73,7 @@ allow_empty_description: true
allow_failing_pipelines: true
allow_failing_tests: true
title_regex: "^[A-Z]+-[0-9]+" # title begins with jira key prefix, e.g. SCO-123 My cool Title
greetings_enabled: true
greetings_template: "Requirements:\n - Min approvals: {{ .MinApprovals }}\n - Title regex: {{ .TitleRegex }}\n\nOnce you've done, send **!merge** command and i will merge it!"
auto_master_merge: true
```
Expand Down
1 change: 1 addition & 0 deletions handlers/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type Config struct {
AllowFailingTests bool `yaml:"allow_failing_tests"`
TitleRegex string `yaml:"title_regex"`
AllowEmptyDescription bool `yaml:"allow_empty_description"`
EnableGreetings bool `yaml:"greetings_enabled"`
GreetingsTemplate string `yaml:"greetings_template"`
AutoMasterMerge bool `yaml:"auto_master_merge"`
}
Expand Down
5 changes: 5 additions & 0 deletions handlers/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (r *Request) ParseConfig(content string) (*Config, error) {
AllowFailingTests: true,
TitleRegex: ".*",
AllowEmptyDescription: true,
EnableGreetings: false,
GreetingsTemplate: "Requirements:\n - Min approvals: {{ .MinApprovals }}\n - Title regex: {{ .TitleRegex }}\n\nOnce you've done, send **!merge** command and i will merge it!",
AutoMasterMerge: false,
}
Expand All @@ -83,6 +84,10 @@ func (r *Request) Greetings(projectId, id int) error {
return err
}

if !r.config.EnableGreetings {
return nil
}

tmpl, err := template.New("greetings").Parse(r.config.GreetingsTemplate)
if err != nil {
return err
Expand Down
Loading