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

Commit

Permalink
Merge pull request #18 from dial-once/master
Browse files Browse the repository at this point in the history
Use env var to overload default approvals, pattern and team name
  • Loading branch information
bradrydzewski authored Jul 18, 2016
2 parents e7064a8 + 629ebcc commit 4cbae5a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 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,13 @@ 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", "")
selfApprovalOff = envflag.Bool("LGTM_SELF_APPROVAL_OFF", false, "")
)

// ParseConfig parses a projects .lgtm file
func ParseConfig(data []byte) (*Config, error) {
return ParseConfigStr(string(data))
Expand All @@ -28,14 +36,18 @@ 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
}
if c.SelfApprovalOff == false {
c.SelfApprovalOff = *selfApprovalOff
}

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

0 comments on commit 4cbae5a

Please sign in to comment.