Skip to content

Commit

Permalink
cmd/gopherbot: allow backporting to the upcoming Go release
Browse files Browse the repository at this point in the history
This change gives gopherbot support to backport to the next major
release (current release + 1). Previously, attempting a backport to
a future release would create backports for the last two major
Go releases. These changes will not affected "please backport" comments
which do not indicate a backport number, as gopherbot should not open
an issue for the future release without being explicitly asked to do so.

Fixes golang/go#27040

Change-Id: I0096680c2ce2e164e6d80203bcf257dadaa97138
Reviewed-on: https://go-review.googlesource.com/131077
Reviewed-by: Filippo Valsorda <[email protected]>
  • Loading branch information
katiehockman committed Aug 23, 2018
1 parent 8dcad78 commit 2cb401a
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cmd/gopherbot/gopherbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ type gopherbot struct {
releases struct {
sync.Mutex
lastUpdate time.Time
major []string // last two releases, like: "1.9", "1.10"
major []string // last two releases and the next upcoming release, like: "1.9", "1.10", "1.11"
}
}

Expand Down Expand Up @@ -1150,8 +1150,8 @@ func (b *gopherbot) onLatestCL(ctx context.Context, cl *maintner.GerritCL, f fun
return nil
}

// getMajorReleases returns the two most recent major Go 1.x releases,
// formatted like []string{"1.9", "1.10"}.
// getMajorReleases returns the two most recent major Go 1.x releases, and
// the next upcoming release, sorted and formatted like []string{"1.9", "1.10", "1.11"}.
func (b *gopherbot) getMajorReleases(ctx context.Context) ([]string, error) {
b.releases.Lock()
defer b.releases.Unlock()
Expand Down Expand Up @@ -1201,11 +1201,16 @@ func (b *gopherbot) getMajorReleases(ctx context.Context) ([]string, error) {
}
sort.Slice(majorReleases, func(i, j int) bool {
ii, _ := strconv.Atoi(majorReleases[i][2:])
jj, _ := strconv.Atoi(majorReleases[i][2:])
jj, _ := strconv.Atoi(majorReleases[j][2:])
return ii < jj
})
// Include the next release in the list of major releases.
lastRelease := majorReleases[len(majorReleases)-1]
lastReleaseVersion, _ := strconv.Atoi(lastRelease[2:])
nextRelease := lastRelease[:2] + strconv.Itoa(lastReleaseVersion+1)
majorReleases = append(majorReleases, nextRelease)
b.releases.lastUpdate = time.Now()
b.releases.major = majorReleases[len(majorReleases)-2:]
b.releases.major = majorReleases[len(majorReleases)-3:]
return b.releases.major, nil
}

Expand Down Expand Up @@ -1251,7 +1256,9 @@ func (b *gopherbot) openCherryPickIssues(ctx context.Context) error {
}
}
if len(selectedReleases) == 0 {
selectedReleases = majorReleases
// Only backport to major releases unless explicitly
// asked to backport to the upcoming release.
selectedReleases = majorReleases[:len(majorReleases)-1]
}
var openedIssues []string
for _, rel := range selectedReleases {
Expand Down

0 comments on commit 2cb401a

Please sign in to comment.