2017-07-19 00:04:23 +03:00
|
|
|
// Copyright 2017 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2018-11-21 04:04:09 +03:00
|
|
|
"encoding/json"
|
2023-08-09 17:24:57 +03:00
|
|
|
"errors"
|
2017-11-08 23:22:15 +03:00
|
|
|
"fmt"
|
2017-07-19 00:04:23 +03:00
|
|
|
"html/template"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"regexp"
|
|
|
|
"sort"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"golang.org/x/build/maintner"
|
2021-08-21 03:38:44 +03:00
|
|
|
"golang.org/x/build/maintner/maintnerd/maintapi/version"
|
2017-07-19 00:04:23 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
labelProposal = "Proposal"
|
|
|
|
|
|
|
|
prefixProposal = "proposal:"
|
|
|
|
prefixDev = "[dev."
|
|
|
|
)
|
|
|
|
|
2017-07-23 00:37:30 +03:00
|
|
|
// titleDirs returns a slice of prefix directories contained in a title. For
|
|
|
|
// devapp,maintner: my cool new change, it will return ["devapp", "maintner"].
|
|
|
|
// If there is no dir prefix, it will return nil.
|
2017-07-19 00:04:23 +03:00
|
|
|
func titleDirs(title string) []string {
|
|
|
|
if i := strings.Index(title, "\n"); i >= 0 {
|
|
|
|
title = title[:i]
|
|
|
|
}
|
|
|
|
title = strings.TrimSpace(title)
|
|
|
|
i := strings.Index(title, ":")
|
|
|
|
if i < 0 {
|
2017-07-23 00:37:30 +03:00
|
|
|
return nil
|
2017-07-19 00:04:23 +03:00
|
|
|
}
|
|
|
|
var (
|
|
|
|
b bytes.Buffer
|
|
|
|
r []string
|
|
|
|
)
|
|
|
|
for j := 0; j < i; j++ {
|
|
|
|
switch title[j] {
|
|
|
|
case ' ':
|
|
|
|
continue
|
|
|
|
case ',':
|
|
|
|
r = append(r, b.String())
|
|
|
|
b.Reset()
|
|
|
|
continue
|
|
|
|
default:
|
|
|
|
b.WriteByte(title[j])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if b.Len() > 0 {
|
|
|
|
r = append(r, b.String())
|
|
|
|
}
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
|
|
|
type releaseData struct {
|
2018-11-21 04:04:09 +03:00
|
|
|
LastUpdated string
|
|
|
|
Sections []section
|
|
|
|
BurndownJSON template.JS
|
2021-08-21 03:38:44 +03:00
|
|
|
CurMilestone string // The title of the current release milestone in GitHub. For example, "Go1.18".
|
2017-07-19 00:04:23 +03:00
|
|
|
|
|
|
|
// dirty is set if this data needs to be updated due to a corpus change.
|
|
|
|
dirty bool
|
|
|
|
}
|
|
|
|
|
|
|
|
type section struct {
|
|
|
|
Title string
|
|
|
|
Count int
|
|
|
|
Groups []group
|
|
|
|
}
|
|
|
|
|
|
|
|
type group struct {
|
|
|
|
Dir string
|
|
|
|
Items []item
|
|
|
|
}
|
|
|
|
|
|
|
|
type item struct {
|
2018-10-30 20:08:57 +03:00
|
|
|
Issue *maintner.GitHubIssue
|
|
|
|
CLs []*gerritCL
|
|
|
|
FirstPerformance bool // set if this item is the first item which is labeled "performance"
|
2017-07-19 00:04:23 +03:00
|
|
|
}
|
|
|
|
|
2017-11-22 22:21:54 +03:00
|
|
|
func (i *item) ReleaseBlocker() bool {
|
|
|
|
if i.Issue == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return i.Issue.HasLabel("release-blocker")
|
|
|
|
}
|
|
|
|
|
2019-06-13 19:27:36 +03:00
|
|
|
func (i *item) EarlyInCycle() bool {
|
|
|
|
return !i.ReleaseBlocker() && i.Issue.HasLabel("early-in-cycle")
|
|
|
|
}
|
|
|
|
|
2017-07-19 00:04:23 +03:00
|
|
|
type itemsBySummary []item
|
|
|
|
|
2018-10-30 20:08:57 +03:00
|
|
|
func (x itemsBySummary) Len() int { return len(x) }
|
|
|
|
func (x itemsBySummary) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
|
|
|
|
func (x itemsBySummary) Less(i, j int) bool {
|
2019-06-13 19:27:36 +03:00
|
|
|
// Sort release-blocker issues to the front
|
|
|
|
ri := x[i].Issue != nil && x[i].Issue.HasLabel("release-blocker")
|
|
|
|
rj := x[j].Issue != nil && x[j].Issue.HasLabel("release-blocker")
|
|
|
|
if ri != rj {
|
|
|
|
return ri
|
|
|
|
}
|
2018-10-30 20:08:57 +03:00
|
|
|
// Sort performance issues to the end.
|
|
|
|
pi := x[i].Issue != nil && x[i].Issue.HasLabel("Performance")
|
|
|
|
pj := x[j].Issue != nil && x[j].Issue.HasLabel("Performance")
|
|
|
|
if pi != pj {
|
|
|
|
return !pi
|
|
|
|
}
|
|
|
|
// Otherwise sort by the item summary.
|
|
|
|
return itemSummary(x[i]) < itemSummary(x[j])
|
|
|
|
}
|
2017-07-19 00:04:23 +03:00
|
|
|
|
|
|
|
func itemSummary(it item) string {
|
|
|
|
if it.Issue != nil {
|
|
|
|
return it.Issue.Title
|
|
|
|
}
|
|
|
|
for _, cl := range it.CLs {
|
|
|
|
return cl.Subject()
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
var milestoneRE = regexp.MustCompile(`^Go1\.(\d+)(|\.(\d+))(|[A-Z].*)$`)
|
|
|
|
|
|
|
|
type milestone struct {
|
|
|
|
title string
|
|
|
|
major, minor int
|
|
|
|
}
|
|
|
|
|
2017-07-23 00:37:30 +03:00
|
|
|
type milestonesByGoVersion []milestone
|
2017-07-19 00:04:23 +03:00
|
|
|
|
2017-07-23 00:37:30 +03:00
|
|
|
func (x milestonesByGoVersion) Len() int { return len(x) }
|
|
|
|
func (x milestonesByGoVersion) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
|
|
|
|
func (x milestonesByGoVersion) Less(i, j int) bool {
|
2017-07-19 00:04:23 +03:00
|
|
|
a, b := x[i], x[j]
|
|
|
|
if a.major != b.major {
|
|
|
|
return a.major < b.major
|
|
|
|
}
|
|
|
|
if a.minor != b.minor {
|
|
|
|
return a.minor < b.minor
|
|
|
|
}
|
|
|
|
return a.title < b.title
|
|
|
|
}
|
|
|
|
|
2017-11-08 20:58:56 +03:00
|
|
|
var annotationRE = regexp.MustCompile(`(?m)^R=(.+)\b`)
|
|
|
|
|
|
|
|
type gerritCL struct {
|
|
|
|
*maintner.GerritCL
|
2019-02-06 00:23:39 +03:00
|
|
|
NoPrefixTitle string // CL title without the directory prefix (e.g., "improve ListenAndServe" without leading "net/http: ").
|
|
|
|
Closed bool
|
|
|
|
Milestone string
|
2017-11-08 20:58:56 +03:00
|
|
|
}
|
|
|
|
|
2017-11-08 23:22:15 +03:00
|
|
|
// ReviewURL returns the code review address of cl.
|
|
|
|
func (cl *gerritCL) ReviewURL() string {
|
|
|
|
s := cl.Project.Server()
|
|
|
|
if s == "go.googlesource.com" {
|
|
|
|
return fmt.Sprintf("https://golang.org/cl/%d", cl.Number)
|
|
|
|
}
|
|
|
|
subd := strings.TrimSuffix(s, ".googlesource.com")
|
|
|
|
if subd == s {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("https://%s-review.googlesource.com/%d", subd, cl.Number)
|
|
|
|
}
|
|
|
|
|
2018-11-21 04:04:09 +03:00
|
|
|
// burndownData is encoded to JSON and embedded in the page for use when
|
|
|
|
// rendering a burndown chart using JavaScript.
|
|
|
|
type burndownData struct {
|
|
|
|
Milestone string `json:"milestone"`
|
|
|
|
Entries []burndownEntry `json:"entries"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type burndownEntry struct {
|
|
|
|
DateStr string `json:"dateStr"` // "12-25"
|
|
|
|
Open int `json:"open"`
|
|
|
|
Blockers int `json:"blockers"`
|
|
|
|
}
|
|
|
|
|
2017-07-19 00:04:23 +03:00
|
|
|
func (s *server) updateReleaseData() {
|
|
|
|
log.Println("Updating release data ...")
|
|
|
|
s.cMu.Lock()
|
|
|
|
defer s.cMu.Unlock()
|
|
|
|
|
2017-11-08 20:58:56 +03:00
|
|
|
dirToCLs := map[string][]*gerritCL{}
|
|
|
|
issueToCLs := map[int32][]*gerritCL{}
|
2017-07-19 00:04:23 +03:00
|
|
|
s.corpus.Gerrit().ForeachProjectUnsorted(func(p *maintner.GerritProject) error {
|
|
|
|
p.ForeachOpenCL(func(cl *maintner.GerritCL) error {
|
|
|
|
if strings.HasPrefix(cl.Subject(), prefixDev) {
|
|
|
|
return nil
|
|
|
|
}
|
2017-11-08 20:58:56 +03:00
|
|
|
|
|
|
|
var (
|
2019-02-06 00:23:39 +03:00
|
|
|
pkgs, title = ParsePrefixedChangeTitle(projectRoot(p), cl.Subject())
|
2017-11-08 20:58:56 +03:00
|
|
|
closed bool
|
|
|
|
closedVersion int32
|
|
|
|
milestone string
|
|
|
|
)
|
|
|
|
for _, m := range cl.Messages {
|
|
|
|
if closed && closedVersion < m.Version {
|
|
|
|
closed = false
|
|
|
|
}
|
|
|
|
sm := annotationRE.FindStringSubmatch(m.Message)
|
|
|
|
if sm == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
val := sm[1]
|
|
|
|
if val == "close" || val == "closed" {
|
|
|
|
closedVersion = m.Version
|
|
|
|
closed = true
|
|
|
|
} else if milestoneRE.MatchString(val) {
|
|
|
|
milestone = val
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gcl := &gerritCL{
|
2019-02-06 00:23:39 +03:00
|
|
|
GerritCL: cl,
|
|
|
|
NoPrefixTitle: title,
|
|
|
|
Closed: closed,
|
|
|
|
Milestone: milestone,
|
2017-11-08 20:58:56 +03:00
|
|
|
}
|
|
|
|
|
2017-07-19 00:04:23 +03:00
|
|
|
for _, r := range cl.GitHubIssueRefs {
|
2017-11-08 20:58:56 +03:00
|
|
|
issueToCLs[r.Number] = append(issueToCLs[r.Number], gcl)
|
2017-07-19 00:04:23 +03:00
|
|
|
}
|
2019-02-06 00:23:39 +03:00
|
|
|
if len(pkgs) == 0 {
|
2017-11-08 20:58:56 +03:00
|
|
|
dirToCLs[""] = append(dirToCLs[""], gcl)
|
2017-07-23 00:37:30 +03:00
|
|
|
} else {
|
2019-02-06 00:23:39 +03:00
|
|
|
for _, p := range pkgs {
|
|
|
|
dirToCLs[p] = append(dirToCLs[p], gcl)
|
2017-07-23 00:37:30 +03:00
|
|
|
}
|
2017-07-19 00:04:23 +03:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
2021-08-21 03:38:44 +03:00
|
|
|
// Determine current milestone based on the highest go1.X tag.
|
|
|
|
var highestGo1X int
|
|
|
|
s.proj.ForeachNonChangeRef(func(ref string, _ maintner.GitHash) error {
|
|
|
|
if !strings.HasPrefix(ref, "refs/tags/go1.") {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
tagName := ref[len("refs/tags/"):]
|
|
|
|
if _, x, _, ok := version.ParseTag(tagName); ok && x > highestGo1X {
|
|
|
|
highestGo1X = x
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
// The title of the current release milestone in GitHub. For example, "Go1.18".
|
|
|
|
curMilestoneTitle := fmt.Sprintf("Go1.%d", highestGo1X+1)
|
|
|
|
// The start date of the current release milestone, approximated by taking the
|
|
|
|
// Go 1.17 release date, and adding 6 months for each successive major release.
|
|
|
|
var monthsSinceGo117Release = time.Month(6 * (highestGo1X - 17))
|
|
|
|
curMilestoneStart := time.Date(2021, time.August+monthsSinceGo117Release, 1, 0, 0, 0, 0, time.UTC)
|
|
|
|
|
2017-07-19 00:04:23 +03:00
|
|
|
dirToIssues := map[string][]*maintner.GitHubIssue{}
|
|
|
|
s.repo.ForeachIssue(func(issue *maintner.GitHubIssue) error {
|
2023-08-09 17:24:57 +03:00
|
|
|
// Only open issues in active milestones are displayed on the page using dirToIssues.
|
|
|
|
if issue.Closed ||
|
|
|
|
issue.Milestone.IsUnknown() || issue.Milestone.Closed || issue.Milestone.IsNone() {
|
2018-11-21 04:04:09 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
dirs := titleDirs(issue.Title)
|
|
|
|
if len(dirs) == 0 {
|
|
|
|
dirToIssues[""] = append(dirToIssues[""], issue)
|
|
|
|
} else {
|
|
|
|
for _, d := range dirs {
|
|
|
|
dirToIssues[d] = append(dirToIssues[d], issue)
|
2017-07-19 00:04:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
2023-08-09 17:24:57 +03:00
|
|
|
// Find issues that have been in the current milestone.
|
|
|
|
var curMilestoneIssues []*maintner.GitHubIssue
|
|
|
|
s.repo.ForeachIssue(func(issue *maintner.GitHubIssue) error {
|
|
|
|
if issue.Closed && issue.ClosedAt.Before(curMilestoneStart) {
|
|
|
|
// Old issue, couldn't be relevant to current milestone.
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if !issue.Milestone.IsUnknown() && issue.Milestone.Title == curMilestoneTitle {
|
|
|
|
// Easy case: the issue is still in current milestone.
|
|
|
|
curMilestoneIssues = append(curMilestoneIssues, issue)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
// Check if the issue was ever in the current milestone.
|
|
|
|
issue.ForeachEvent(func(e *maintner.GitHubIssueEvent) error {
|
|
|
|
if e.Type == "milestoned" && e.Milestone == curMilestoneTitle {
|
|
|
|
curMilestoneIssues = append(curMilestoneIssues, issue)
|
|
|
|
return errStopIteration
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
2018-11-21 04:04:09 +03:00
|
|
|
bd := burndownData{Milestone: curMilestoneTitle}
|
|
|
|
for t, now := curMilestoneStart, time.Now(); t.Before(now); t = t.Add(24 * time.Hour) {
|
|
|
|
var e burndownEntry
|
|
|
|
for _, issue := range curMilestoneIssues {
|
|
|
|
if issue.Created.After(t) || (issue.Closed && issue.ClosedAt.Before(t)) {
|
|
|
|
continue
|
|
|
|
}
|
2023-08-09 17:24:57 +03:00
|
|
|
var inCurMilestoneAtT bool
|
|
|
|
issue.ForeachEvent(func(e *maintner.GitHubIssueEvent) error {
|
|
|
|
if e.Created.After(t) {
|
|
|
|
return errStopIteration
|
|
|
|
}
|
|
|
|
switch e.Type {
|
|
|
|
case "milestoned":
|
|
|
|
inCurMilestoneAtT = e.Milestone == curMilestoneTitle
|
|
|
|
case "demilestoned":
|
|
|
|
inCurMilestoneAtT = false
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
if !inCurMilestoneAtT {
|
|
|
|
continue
|
|
|
|
}
|
2018-11-21 04:04:09 +03:00
|
|
|
if issue.HasLabel("release-blocker") {
|
|
|
|
e.Blockers++
|
|
|
|
}
|
|
|
|
e.Open++
|
|
|
|
}
|
|
|
|
e.DateStr = t.Format("01-02")
|
|
|
|
bd.Entries = append(bd.Entries, e)
|
|
|
|
}
|
|
|
|
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := json.NewEncoder(&buf).Encode(bd); err != nil {
|
|
|
|
log.Printf("json.Encode: %v", err)
|
|
|
|
}
|
|
|
|
s.data.release.BurndownJSON = template.JS(buf.String())
|
2017-09-20 23:27:09 +03:00
|
|
|
s.data.release.Sections = nil
|
2017-07-19 00:04:23 +03:00
|
|
|
s.appendOpenIssues(dirToIssues, issueToCLs)
|
|
|
|
s.appendPendingCLs(dirToCLs)
|
|
|
|
s.appendPendingProposals(issueToCLs)
|
|
|
|
s.appendClosedIssues()
|
2021-08-21 03:38:44 +03:00
|
|
|
s.data.release.CurMilestone = curMilestoneTitle
|
2017-09-20 23:27:09 +03:00
|
|
|
s.data.release.LastUpdated = time.Now().UTC().Format(time.UnixDate)
|
|
|
|
s.data.release.dirty = false
|
2017-07-19 00:04:23 +03:00
|
|
|
}
|
|
|
|
|
2019-02-06 00:23:39 +03:00
|
|
|
// projectRoot returns the import path corresponding to the repo root
|
|
|
|
// of the Gerrit project p. For golang.org/x subrepos, the golang.org
|
|
|
|
// part is omitted for previty.
|
|
|
|
func projectRoot(p *maintner.GerritProject) string {
|
|
|
|
switch p.Server() {
|
|
|
|
case "go.googlesource.com":
|
|
|
|
switch subrepo := p.Project(); subrepo {
|
|
|
|
case "go":
|
|
|
|
// Main Go repo.
|
|
|
|
return ""
|
|
|
|
case "dl":
|
|
|
|
// dl is a special subrepo, there's no /x/ in its import path.
|
|
|
|
return "golang.org/dl"
|
|
|
|
case "gddo":
|
|
|
|
// There is no golang.org/x/gddo vanity import path, and
|
|
|
|
// the canonical import path for gddo is on GitHub.
|
|
|
|
return "github.com/golang/gddo"
|
|
|
|
default:
|
|
|
|
// For brevity, use x/subrepo rather than golang.org/x/subrepo.
|
|
|
|
return "x/" + subrepo
|
|
|
|
}
|
|
|
|
case "code.googlesource.com":
|
|
|
|
switch p.Project() {
|
|
|
|
case "gocloud":
|
|
|
|
return "cloud.google.com/go"
|
|
|
|
case "google-api-go-client":
|
|
|
|
return "google.golang.org/api"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return p.ServerSlashProject()
|
|
|
|
}
|
|
|
|
|
2017-07-19 00:04:23 +03:00
|
|
|
// requires s.cMu be locked.
|
2017-11-08 20:58:56 +03:00
|
|
|
func (s *server) appendOpenIssues(dirToIssues map[string][]*maintner.GitHubIssue, issueToCLs map[int32][]*gerritCL) {
|
2017-07-19 00:04:23 +03:00
|
|
|
var issueDirs []string
|
|
|
|
for d := range dirToIssues {
|
|
|
|
issueDirs = append(issueDirs, d)
|
|
|
|
}
|
|
|
|
sort.Strings(issueDirs)
|
|
|
|
ms := s.allMilestones()
|
|
|
|
for _, m := range ms {
|
|
|
|
var (
|
|
|
|
issueGroups []group
|
|
|
|
issueCount int
|
|
|
|
)
|
|
|
|
for _, d := range issueDirs {
|
|
|
|
issues, ok := dirToIssues[d]
|
|
|
|
if !ok {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
var items []item
|
|
|
|
for _, i := range issues {
|
|
|
|
if i.Milestone.Title != m.title {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
items = append(items, item{
|
|
|
|
Issue: i,
|
|
|
|
CLs: issueToCLs[i.Number],
|
|
|
|
})
|
|
|
|
issueCount++
|
|
|
|
}
|
|
|
|
if len(items) == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
sort.Sort(itemsBySummary(items))
|
2018-10-30 20:08:57 +03:00
|
|
|
for idx := range items {
|
2019-12-03 21:11:58 +03:00
|
|
|
if items[idx].Issue.HasLabel("Performance") && !items[idx].Issue.HasLabel("release-blocker") {
|
2018-10-30 20:08:57 +03:00
|
|
|
items[idx].FirstPerformance = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2017-07-19 00:04:23 +03:00
|
|
|
issueGroups = append(issueGroups, group{
|
|
|
|
Dir: d,
|
|
|
|
Items: items,
|
|
|
|
})
|
|
|
|
}
|
2017-09-20 23:27:09 +03:00
|
|
|
s.data.release.Sections = append(s.data.release.Sections, section{
|
2017-07-19 00:04:23 +03:00
|
|
|
Title: m.title,
|
|
|
|
Count: issueCount,
|
|
|
|
Groups: issueGroups,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// requires s.cMu be locked.
|
2017-11-08 20:58:56 +03:00
|
|
|
func (s *server) appendPendingCLs(dirToCLs map[string][]*gerritCL) {
|
2017-07-19 00:04:23 +03:00
|
|
|
var clDirs []string
|
|
|
|
for d := range dirToCLs {
|
|
|
|
clDirs = append(clDirs, d)
|
|
|
|
}
|
|
|
|
sort.Strings(clDirs)
|
|
|
|
var (
|
|
|
|
clGroups []group
|
|
|
|
clCount int
|
|
|
|
)
|
|
|
|
for _, d := range clDirs {
|
|
|
|
if cls, ok := dirToCLs[d]; ok {
|
|
|
|
clCount += len(cls)
|
|
|
|
g := group{Dir: d}
|
|
|
|
g.Items = append(g.Items, item{CLs: cls})
|
|
|
|
sort.Sort(itemsBySummary(g.Items))
|
|
|
|
clGroups = append(clGroups, g)
|
|
|
|
}
|
|
|
|
}
|
2017-09-20 23:27:09 +03:00
|
|
|
s.data.release.Sections = append(s.data.release.Sections, section{
|
2017-07-19 00:04:23 +03:00
|
|
|
Title: "Pending CLs",
|
|
|
|
Count: clCount,
|
|
|
|
Groups: clGroups,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// requires s.cMu be locked.
|
2017-11-08 20:58:56 +03:00
|
|
|
func (s *server) appendPendingProposals(issueToCLs map[int32][]*gerritCL) {
|
2017-07-19 00:04:23 +03:00
|
|
|
var proposals group
|
|
|
|
s.repo.ForeachIssue(func(issue *maintner.GitHubIssue) error {
|
|
|
|
if issue.Closed {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if issue.HasLabel(labelProposal) || strings.HasPrefix(issue.Title, prefixProposal) {
|
|
|
|
proposals.Items = append(proposals.Items, item{
|
|
|
|
Issue: issue,
|
|
|
|
CLs: issueToCLs[issue.Number],
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
sort.Sort(itemsBySummary(proposals.Items))
|
2017-09-20 23:27:09 +03:00
|
|
|
s.data.release.Sections = append(s.data.release.Sections, section{
|
2017-07-19 00:04:23 +03:00
|
|
|
Title: "Pending Proposals",
|
|
|
|
Count: len(proposals.Items),
|
|
|
|
Groups: []group{proposals},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// requires s.cMu be locked.
|
|
|
|
func (s *server) appendClosedIssues() {
|
|
|
|
var (
|
|
|
|
closed group
|
|
|
|
lastWeek = time.Now().Add(-(7*24 + 12) * time.Hour)
|
|
|
|
)
|
|
|
|
s.repo.ForeachIssue(func(issue *maintner.GitHubIssue) error {
|
|
|
|
if !issue.Closed {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if issue.Updated.After(lastWeek) {
|
|
|
|
closed.Items = append(closed.Items, item{Issue: issue})
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
sort.Sort(itemsBySummary(closed.Items))
|
2017-09-20 23:27:09 +03:00
|
|
|
s.data.release.Sections = append(s.data.release.Sections, section{
|
2017-07-19 00:04:23 +03:00
|
|
|
Title: "Closed Last Week",
|
|
|
|
Count: len(closed.Items),
|
|
|
|
Groups: []group{closed},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// requires s.cMu be read locked.
|
|
|
|
func (s *server) allMilestones() []milestone {
|
|
|
|
var ms []milestone
|
|
|
|
s.repo.ForeachMilestone(func(m *maintner.GitHubMilestone) error {
|
|
|
|
if m.Closed {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
sm := milestoneRE.FindStringSubmatch(m.Title)
|
|
|
|
if sm == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
major, _ := strconv.Atoi(sm[1])
|
|
|
|
minor, _ := strconv.Atoi(sm[3])
|
|
|
|
ms = append(ms, milestone{
|
|
|
|
title: m.Title,
|
|
|
|
major: major,
|
|
|
|
minor: minor,
|
|
|
|
})
|
|
|
|
return nil
|
|
|
|
})
|
2017-07-23 00:37:30 +03:00
|
|
|
sort.Sort(milestonesByGoVersion(ms))
|
2017-07-19 00:04:23 +03:00
|
|
|
return ms
|
|
|
|
}
|
|
|
|
|
|
|
|
// handleRelease serves dev.golang.org/release.
|
|
|
|
func (s *server) handleRelease(t *template.Template, w http.ResponseWriter, r *http.Request) {
|
|
|
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
|
|
s.cMu.RLock()
|
2017-09-20 23:27:09 +03:00
|
|
|
dirty := s.data.release.dirty
|
2017-07-19 00:04:23 +03:00
|
|
|
s.cMu.RUnlock()
|
|
|
|
if dirty {
|
|
|
|
s.updateReleaseData()
|
|
|
|
}
|
|
|
|
|
|
|
|
s.cMu.RLock()
|
|
|
|
defer s.cMu.RUnlock()
|
2017-09-20 23:27:09 +03:00
|
|
|
if err := t.Execute(w, s.data.release); err != nil {
|
2017-07-19 00:04:23 +03:00
|
|
|
log.Printf("t.Execute(w, nil) = %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2023-08-09 17:24:57 +03:00
|
|
|
|
|
|
|
// errStopIteration is used to stop iteration over issues or comments.
|
|
|
|
// It has no special meaning.
|
|
|
|
var errStopIteration = errors.New("stop iteration")
|