From b0531cf7ccfe6e13b88eddc4029edf4b0733c26e Mon Sep 17 00:00:00 2001 From: Julien Kernec'h Date: Tue, 10 May 2016 17:37:27 +0200 Subject: [PATCH 1/2] Use env var to overload default approvals, pattern and team name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- model/config.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/model/config.go b/model/config.go index a4c2599..cc2232b 100644 --- a/model/config.go +++ b/model/config.go @@ -4,6 +4,7 @@ import ( "regexp" "github.com/BurntSushi/toml" + "github.com/ianschenck/envflag" ) type Config struct { @@ -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)) @@ -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 } From 629ebcce606362d8de9c0fd95909a825d3f03508 Mon Sep 17 00:00:00 2001 From: Julien Kernec'h Date: Mon, 16 May 2016 22:18:02 +0200 Subject: [PATCH 2/2] Use env var to overload default selfApprovalOff --- model/config.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/model/config.go b/model/config.go index cc2232b..bf6d63e 100644 --- a/model/config.go +++ b/model/config.go @@ -20,6 +20,7 @@ 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 @@ -43,6 +44,9 @@ func ParseConfigStr(data string) (*Config, error) { if len(c.Team) == 0 { c.Team = *team } + if c.SelfApprovalOff == false { + c.SelfApprovalOff = *selfApprovalOff + } c.re, err = regexp.Compile(c.Pattern) return c, err