From 138305354251f8cbc25b071d026832328f5caba8 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 5 Oct 2021 21:27:25 +0200 Subject: [PATCH] wip --- model/config.go | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/model/config.go b/model/config.go index 06ed6af..d6911ad 100644 --- a/model/config.go +++ b/model/config.go @@ -2,6 +2,7 @@ package model import ( "regexp" + "strings" "github.com/BurntSushi/toml" "github.com/ianschenck/envflag" @@ -9,11 +10,13 @@ import ( // Config represents a repo-specific configuration file. type Config struct { - Approvals int `json:"approvals" toml:"approvals"` - Pattern string `json:"pattern" toml:"pattern"` - Team string `json:"team" toml:"team"` - SelfApprovalOff bool `json:"self_approval_off" toml:"self_approval_off"` - IgnoreMaintainersFile bool `json:"ignore_maintainers_file" toml:"ignore_maintainers_file"` + Approvals int `json:"approvals" toml:"approvals"` + Pattern string `json:"pattern" toml:"pattern"` + Teams []string `json:"team" toml:"teams"` + SelfApprovalOff bool `json:"self_approval_off" toml:"self_approval_off"` + IgnoreMaintainersFile bool `json:"ignore_maintainers_file" toml:"ignore_maintainers_file"` + // deprecated + Team string `json:"team" toml:"team"` re *regexp.Regexp } @@ -21,9 +24,12 @@ type Config struct { var ( approvals = envflag.Int("LGTM_APPROVALS", 2, "") pattern = envflag.String("LGTM_PATTERN", "(?i)LGTM", "") - team = envflag.String("LGTM_TEAM", "MAINTAINERS", "") + teams = envflag.String("LGTM_TEAMS", "MAINTAINERS", "") selfApprovalOff = envflag.Bool("LGTM_SELF_APPROVAL_OFF", false, "") ignoreMaintainersFile = envflag.Bool("IGNORE_MAINTAINERS_FILE", false, "") + + // deprecated + team = envflag.String("LGTM_TEAM", "", "") ) // ParseConfig parses a projects .lgtm file @@ -47,6 +53,15 @@ func ParseConfigStr(data string) (*Config, error) { if len(c.Team) == 0 { c.Team = *team } + if len(c.Teams) == 0 { + if len(*teams) != 0 { + for _, t := range strings.Split(*teams, ",") { + c.Teams = append(c.Teams, strings.TrimSpace(t)) + } + } else { + c.Teams = []string{c.Team} + } + } if c.SelfApprovalOff == false { c.SelfApprovalOff = *selfApprovalOff }