Skip to content

Commit def9358

Browse files
dmitshurgopherbot
authored andcommitted
cmd/gopherbot: handle gone issues in setMilestone too
The "label proposals" task adds the "Proposal" label and sets the "Proposal" milestone, whichever is missing, to proposal issues. It got stuck processing a no-longer-existing proposal issue 67913: milestone-Proposal https://go.dev/issue/67913 proposal: exp/xerrors: add try and handle 2024/06/17 15:24:10 label proposals: PATCH https://github.com/api/repos/golang/go/issues/67913: 404 Not Found [] 2024/06/17 15:24:10 gopherbot ran in 33.445731908s 2024/06/17 15:24:10 sleeping 30s after previous error. Because it happens to set the milestone first, and setting the milestone was missing the path to add to deletedIssues to work around for maintner not reflecting deleted issues in its corpus (see go.dev/issue/30184). Add that path to setMilestone. Also make the task add label first, set milestone second, for consistency with the task's description. While here, also mark a few issues that are known to be gone. Tested in -dry-run mode. For golang/go#28320. Updates golang/go#30184. Change-Id: I5878c944c8e8f52ab375cd433032953fb8a58d54 Reviewed-on: https://go-review.googlesource.com/c/build/+/593056 Reviewed-by: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent d6ee231 commit def9358

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

cmd/gopherbot/gopherbot.go

+19-7
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ func main() {
330330
{goRepo, 40593}: true,
331331
{goRepo, 40600}: true,
332332
{goRepo, 41211}: true,
333+
{goRepo, 41268}: true, // transferred to https://github.com/golang/tour/issues/1042
333334
{goRepo, 41336}: true,
334335
{goRepo, 41649}: true,
335336
{goRepo, 41650}: true,
@@ -365,6 +366,8 @@ func main() {
365366
{goRepo, 45201}: true,
366367
{goRepo, 45202}: true,
367368
{goRepo, 47140}: true,
369+
{goRepo, 62987}: true,
370+
{goRepo, 67913}: true,
368371

369372
{vscode, 298}: true,
370373
{vscode, 524}: true,
@@ -373,6 +376,9 @@ func main() {
373376
{vscode, 773}: true,
374377
{vscode, 959}: true,
375378
{vscode, 1402}: true,
379+
{vscode, 2260}: true, // transferred to https://go.dev/issue/53080
380+
{vscode, 2548}: true,
381+
{vscode, 2781}: true, // transferred to https://go.dev/issue/60435
376382
},
377383
}
378384
for n := int32(55359); n <= 55828; n++ {
@@ -639,9 +645,15 @@ func (b *gopherbot) setMilestone(ctx context.Context, repoID maintner.GitHubRepo
639645
if *dryRun {
640646
return nil
641647
}
642-
_, _, err := b.ghc.Issues.Edit(ctx, repoID.Owner, repoID.Repo, int(gi.Number), &github.IssueRequest{
648+
_, resp, err := b.ghc.Issues.Edit(ctx, repoID.Owner, repoID.Repo, int(gi.Number), &github.IssueRequest{
643649
Milestone: github.Int(m.Number),
644650
})
651+
if err != nil && resp != nil && (resp.StatusCode == http.StatusNotFound || resp.StatusCode == http.StatusGone) {
652+
// An issue can become gone on GitHub without maintner realizing it. See go.dev/issue/30184.
653+
log.Printf("setMilestone: Issue %v#%v returned %s when trying to set milestone. Skipping. See go.dev/issue/30184.", repoID, gi.Number, resp.Status)
654+
b.deletedIssues[githubIssue{repoID, gi.Number}] = true
655+
return nil
656+
}
645657
return err
646658
}
647659

@@ -954,18 +966,18 @@ func (b *gopherbot) labelProposals(ctx context.Context) error {
954966
if !strings.HasPrefix(gi.Title, "proposal:") && !strings.HasPrefix(gi.Title, "Proposal:") {
955967
return nil
956968
}
957-
// Add Milestone if missing:
958-
if gi.Milestone.IsNone() && !gi.HasEvent("milestoned") && !gi.HasEvent("demilestoned") {
959-
if err := b.setMilestone(ctx, b.gorepo.ID(), gi, proposal); err != nil {
960-
return err
961-
}
962-
}
963969
// Add Proposal label if missing:
964970
if !gi.HasLabel("Proposal") && !gi.HasEvent("unlabeled") {
965971
if err := b.addLabel(ctx, b.gorepo.ID(), gi, "Proposal"); err != nil {
966972
return err
967973
}
968974
}
975+
// Add Milestone if missing:
976+
if gi.Milestone.IsNone() && !gi.HasEvent("milestoned") && !gi.HasEvent("demilestoned") {
977+
if err := b.setMilestone(ctx, b.gorepo.ID(), gi, proposal); err != nil {
978+
return err
979+
}
980+
}
969981

970982
// Remove NeedsDecision label if exists, but not for Go 2 issues:
971983
if !isGo2Issue(gi) && gi.HasLabel("NeedsDecision") && !gopherbotRemovedLabel(gi, "NeedsDecision") {

0 commit comments

Comments
 (0)