Skip to content
This repository has been archived by the owner on Mar 26, 2022. It is now read-only.

Commit

Permalink
Use env var to overload default approvals, pattern and team name
Browse files Browse the repository at this point in the history
LGTM_APPROVALS for the number of approvals (default 2)
LGTM_PATTERN for the pattern (default “(?i)LGTM”)
LGTM_TEAM for the team name (default MAINTAINERS)
  • Loading branch information
Julien Kernec'h committed May 10, 2016
1 parent 2836d86 commit b0531cf
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions model/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"regexp"

"github.com/BurntSushi/toml"
"github.com/ianschenck/envflag"
)

type Config struct {
Expand All @@ -15,6 +16,12 @@ type Config struct {
re *regexp.Regexp
}

var (
approvals = envflag.Int("LGTM_APPROVALS", 2, "")
pattern = envflag.String("LGTM_PATTERN", "(?i)LGTM", "")
team = envflag.String("LGTM_TEAM", "MAINTAINERS", "")
)

// ParseConfig parses a projects .lgtm file
func ParseConfig(data []byte) (*Config, error) {
return ParseConfigStr(string(data))
Expand All @@ -28,14 +35,15 @@ func ParseConfigStr(data string) (*Config, error) {
return nil, err
}
if c.Approvals == 0 {
c.Approvals = 2
c.Approvals = *approvals
}
if len(c.Pattern) == 0 {
c.Pattern = "(?i)LGTM"
c.Pattern = *pattern
}
if len(c.Team) == 0 {
c.Team = "MAINTAINERS"
c.Team = *team
}

c.re, err = regexp.Compile(c.Pattern)
return c, err
}
Expand Down

0 comments on commit b0531cf

Please sign in to comment.