diff --git a/cmd/gopherbot/gopherbot.go b/cmd/gopherbot/gopherbot.go
index c93bbeb..a2b6e26 100644
--- a/cmd/gopherbot/gopherbot.go
+++ b/cmd/gopherbot/gopherbot.go
@@ -1896,7 +1896,7 @@
func (b *gopherbot) closeCherryPickIssues(ctx context.Context) error {
cherryPickIssues := make(map[int32]*maintner.GitHubIssue) // by GitHub Issue Number
b.foreachIssue(b.gorepo, open, func(gi *maintner.GitHubIssue) error {
- if gi.Milestone.IsNone() || gi.HasEvent("reopened") {
+ if gi.Milestone.IsNone() {
return nil
}
if !strings.HasPrefix(gi.Milestone.Title, "Go") {
@@ -1933,6 +1933,11 @@
// doesn't match the CL branch goX.Y version, so skip it.
continue
}
+ if issueLastOpened(gi).After(cl.Commit.CommitTime) {
+ // The issue was opened (or more likely, reopened) after this CL was submitted,
+ // so skip it.
+ continue
+ }
printIssue("close-cherry-pick", ref.Repo.ID(), gi)
if err := b.addGitHubComment(ctx, ref.Repo, gi.Number, fmt.Sprintf(
"Closed by merging [CL %d](https://go.dev/cl/%d) (commit %s) to `%s`.", cl.Number, cl.Number, cl.Commit.Hash, cl.Branch())); err != nil {
@@ -1945,6 +1950,19 @@
})
}
+// issueLastOpened reports the most recent time that the issue
+// had an "opened" or "reopened" event.
+func issueLastOpened(gi *maintner.GitHubIssue) time.Time {
+ last := gi.Created
+ gi.ForeachEvent(func(e *maintner.GitHubIssueEvent) error {
+ if e.Type == "reopened" {
+ last = e.Created
+ }
+ return nil
+ })
+ return last
+}
+
// closeLUCIConfigIssues closes specified issues when CLs are merged to the
// luci-config branch, as GitHub only does that on merge to the main branch.
func (b *gopherbot) closeLUCIConfigIssues(ctx context.Context) error {