From 7b98da62869a15aa14851140ba9b779bd39a9912 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Sat, 14 Nov 2020 08:32:38 -0500 Subject: [PATCH] github: convert filter to array --- plugins/git/github.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/git/github.go b/plugins/git/github.go index 2e6f8c4..d5dd728 100644 --- a/plugins/git/github.go +++ b/plugins/git/github.go @@ -38,15 +38,18 @@ func (p *GitPlugin) githubEvent(w http.ResponseWriter, r *http.Request) { repo = push.Repository.Name owner = push.Repository.Owner.Login commits := "" - filterBranch := p.c.Get(fmt.Sprintf("github.%s.%s.branches", owner, repo), "*") + filterBranches := p.c.GetArray(fmt.Sprintf("github.%s.%s.branches", owner, repo), []string{"*"}) if len(push.Commits) == 0 { log.Debug().Msg("GitHub sent an empty changeset") return } - if filterBranch != "*" && !strings.Contains(push.Ref, filterBranch) { - log.Debug().Msgf("Ignoring GitHub push to %s", push.Ref) - return + for _, filterBranch := range filterBranches { + if filterBranch == "*" || strings.Contains(push.Ref, filterBranch) { + goto processBranch + } } + return + processBranch: for _, c := range push.Commits { m := strings.Split(c.Message, "\n")[0] commits += fmt.Sprintf("%s %s pushed to %s (<%s|%s>) %s\n",