cmd/gopherbot: add a Gopherbot comment requesting more gopls information
Since we can't add another GitHub issue template specifically for gopls,
have Gopherbot add a comment requesting more information. For now, the
comment just links to the Troubleshooting wiki page, but we can make it
more sophisticated if necessary.
Change-Id: Iec7e5f8347caa6132416df305bbd7f2c1db45eef
Reviewed-on: https://go-review.googlesource.com/c/build/+/190401
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/cmd/gopherbot/gopherbot.go b/cmd/gopherbot/gopherbot.go
index 321cbd3..11f6ce8 100644
--- a/cmd/gopherbot/gopherbot.go
+++ b/cmd/gopherbot/gopherbot.go
@@ -284,7 +284,7 @@
{"label build issues", (*gopherbot).labelBuildIssues},
{"label mobile issues", (*gopherbot).labelMobileIssues},
{"label documentation issues", (*gopherbot).labelDocumentationIssues},
- {"label gopls issues", (*gopherbot).labelGoplsIssues},
+ {"handle gopls issues", (*gopherbot).handleGoplsIssues},
{"close stale WaitingForInfo", (*gopherbot).closeStaleWaitingForInfo},
{"cl2issue", (*gopherbot).cl2issue},
{"update needs", (*gopherbot).updateNeeds},
@@ -865,12 +865,23 @@
})
}
-func (b *gopherbot) labelGoplsIssues(ctx context.Context) error {
+// handleGoplsIssues labels and asks for additional information on gopls issues.
+//
+// This is necessary because gopls issues often require additional information to diagnose,
+// and we don't ask for this information in the Go issue template.
+func (b *gopherbot) handleGoplsIssues(ctx context.Context) error {
return b.gorepo.ForeachIssue(func(gi *maintner.GitHubIssue) error {
if gi.Closed || gi.PullRequest || !isGoplsTitle(gi.Title) || gi.HasLabel("gopls") || gi.HasEvent("unlabeled") {
return nil
}
- return b.addLabel(ctx, gi, "gopls")
+ if err := b.addLabel(ctx, gi, "gopls"); err != nil {
+ return err
+ }
+ // Request more information from the user.
+ const comment = "Thank you for filing a gopls issue! Please take a look at the " +
+ "[Troubleshooting](https://github.com/golang/go/wiki/gopls#troubleshooting) section of the gopls Wiki page, " +
+ "and make sure that you have provided all of the relevant information here."
+ return b.addGitHubComment(ctx, "golang", "go", gi.Number, comment)
})
}