From 6f4d935cca8a2122721841c5842585add838b05b Mon Sep 17 00:00:00 2001 From: Leigh McCulloch Date: Fri, 20 Jul 2018 04:54:57 +0000 Subject: [PATCH] cmd/gopherbot: add has-cl label to issues with CL For contributors looking for new issues to contribute to it can be difficult to find issues that need a fix and don't already have a fix being considered. There are several labels that help guide the way already, like NeedsFix, HelpWanted. But many issues with this label will already have a CL. There's currently no way to identify with a GitHub search which issues have CLs and which do not. It'd be helpful to be able to search for issues that do not have a CL and a label on issues that have a CL is a simple method to distinguishing issues that do or do not have a CL. Fixes #26494 --- cmd/gopherbot/gopherbot.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmd/gopherbot/gopherbot.go b/cmd/gopherbot/gopherbot.go index ae56698143..b6cff015eb 100644 --- a/cmd/gopherbot/gopherbot.go +++ b/cmd/gopherbot/gopherbot.go @@ -808,6 +808,7 @@ func (b *gopherbot) closeStaleWaitingForInfo(ctx context.Context) error { // cl2issue writes "Change https://golang.org/issue/NNNN mentions this issue"\ // and the change summary on GitHub when a new Gerrit change references a GitHub issue. +// It also labels the issue as "has-cl". func (b *gopherbot) cl2issue(ctx context.Context) error { monthAgo := time.Now().Add(-30 * 24 * time.Hour) return b.corpus.Gerrit().ForeachProjectUnsorted(func(gp *maintner.GerritProject) error { @@ -846,6 +847,19 @@ func (b *gopherbot) cl2issue(ctx context.Context) error { return err } } + needsHasCLLabel := !gi.HasLabel("has-cl") + gi.ForeachEvent(func(c *maintner.GitHubIssueEvent) error { + if c.Type == "unlabeled" && c.Label == "has-cl" { + needsHasCLLabel = false + return errStopIteration + } + return nil + }) + if needsHasCLLabel { + if err := b.addLabel(ctx, gi, "has-cl"); err != nil { + return err + } + } } return nil })