@@ -12,10 +12,12 @@ import (
12
12
"flag"
13
13
"fmt"
14
14
"html"
15
- "io/ioutil"
16
15
"log"
16
+ "os"
17
17
"path"
18
+ "path/filepath"
18
19
"regexp"
20
+ "runtime"
19
21
"sort"
20
22
"strconv"
21
23
"strings"
@@ -27,11 +29,7 @@ import (
27
29
"golang.org/x/build/repos"
28
30
)
29
31
30
- var (
31
- verbose = flag .Bool ("v" , false , "print verbose logging" )
32
- htmlMode = flag .Bool ("html" , false , "write HTML output" )
33
- exclFile = flag .String ("exclude-from" , "" , "optional path to release notes HTML file. If specified, any 'CL NNNN' occurrence in the content will cause that CL to be excluded from this tool's output." )
34
- )
32
+ var verbose = flag .Bool ("v" , false , "print verbose logging" )
35
33
36
34
// change is a change that was noted via a RELNOTE= comment.
37
35
type change struct {
@@ -95,6 +93,22 @@ func main() {
95
93
log .SetFlags (0 )
96
94
flag .Parse ()
97
95
96
+ goroot := runtime .GOROOT ()
97
+ if goroot == "" {
98
+ log .Fatalf ("missing GOROOT" )
99
+ }
100
+
101
+ // Read internal/goversion to find the next release.
102
+ data , err := os .ReadFile (filepath .Join (goroot , "src/internal/goversion/goversion.go" ))
103
+ if err != nil {
104
+ log .Fatal (err )
105
+ }
106
+ m := regexp .MustCompile (`Version = (\d+)` ).FindStringSubmatch (string (data ))
107
+ if m == nil {
108
+ log .Fatalf ("cannot find Version in src/internal/goversion/goversion.go" )
109
+ }
110
+ version := m [1 ]
111
+
98
112
// Releases are every 6 months. Walk forward by 6 month increments to next release.
99
113
cutoff := time .Date (2016 , time .August , 1 , 00 , 00 , 00 , 0 , time .UTC )
100
114
now := time .Now ()
@@ -114,13 +128,9 @@ func main() {
114
128
log .Fatal (err )
115
129
}
116
130
117
- var existingHTML []byte
118
- if * exclFile != "" {
119
- var err error
120
- existingHTML , err = ioutil .ReadFile (* exclFile )
121
- if err != nil {
122
- log .Fatal (err )
123
- }
131
+ existingHTML , err := os .ReadFile (filepath .Join (goroot , "doc/go1." + version + ".html" ))
132
+ if err != nil {
133
+ log .Fatal (err )
124
134
}
125
135
126
136
corpus , err := godata .Get (context .Background ())
@@ -213,34 +223,30 @@ func main() {
213
223
}
214
224
sort .Strings (pkgs )
215
225
216
- if * htmlMode {
217
- for _ , pkg := range pkgs {
218
- if ! strings . HasPrefix ( pkg , "cmd/" ) {
219
- continue
220
- }
221
- for _ , change := range changes [ pkg ] {
222
- fmt . Printf ( "<!-- %s: %s --> \n " , change . ID (), change . TextLine ())
223
- }
226
+ // TODO(rsc): Instead of making people do the mechanical work of
227
+ // copy and pasting this TODO HTML into the release notes,
228
+ // relnote should edit the release notes directly to insert the TODOs.
229
+ // Then it should print to standard output only a summary of the
230
+ // changes it made.
231
+ for _ , pkg := range pkgs {
232
+ if ! strings . HasPrefix ( pkg , "cmd/" ) {
233
+ continue
224
234
}
225
- for _ , pkg := range pkgs {
226
- if strings .HasPrefix (pkg , "cmd/" ) {
227
- continue
228
- }
229
- fmt .Printf ("\n <dl id=%q><dt><a href=%q>%s</a></dt>\n <dd>" ,
230
- pkg , "/pkg/" + pkg + "/" , pkg )
231
- for _ , change := range changes [pkg ] {
232
- fmt .Printf ("\n <p><!-- %s -->\n TODO: <a href=%q>%s</a>: %s\n </p>\n " ,
233
- change .ID (), change .URL (), change .URL (), html .EscapeString (change .TextLine ()))
234
- }
235
- fmt .Printf (" </dd>\n </dl><!-- %s -->\n " , pkg )
235
+ for _ , change := range changes [pkg ] {
236
+ fmt .Printf ("<!-- %s -->\n <p>\n <!-- %s -->\n </p>\n " , change .ID (), change .TextLine ())
236
237
}
237
- } else {
238
- for _ , pkg := range pkgs {
239
- fmt .Printf ("%s\n " , pkg )
240
- for _ , change := range changes [pkg ] {
241
- fmt .Printf (" %s: %s\n " , change .URL (), change .TextLine ())
242
- }
238
+ }
239
+ for _ , pkg := range pkgs {
240
+ if strings .HasPrefix (pkg , "cmd/" ) {
241
+ continue
242
+ }
243
+ fmt .Printf ("\n <dl id=%q><dt><a href=%q>%s</a></dt>\n <dd>" ,
244
+ pkg , "/pkg/" + pkg + "/" , pkg )
245
+ for _ , change := range changes [pkg ] {
246
+ fmt .Printf ("\n <p><!-- %s -->\n TODO: <a href=%q>%s</a>: %s\n </p>\n " ,
247
+ change .ID (), change .URL (), change .URL (), html .EscapeString (change .TextLine ()))
243
248
}
249
+ fmt .Printf (" </dd>\n </dl><!-- %s -->\n " , pkg )
244
250
}
245
251
}
246
252
@@ -354,7 +360,7 @@ func hasLabel(issue *maintner.GitHubIssue, label string) bool {
354
360
return false
355
361
}
356
362
357
- var numbersRE = regexp .MustCompile (`(?m)(?:^|\s)#([0-9]{3,})` )
363
+ var numbersRE = regexp .MustCompile (`(?m)(?:^|\s|golang/go )#([0-9]{3,})` )
358
364
var golangGoNumbersRE = regexp .MustCompile (`(?m)golang/go#([0-9]{3,})` )
359
365
360
366
// issueNumbers returns the golang/go issue numbers referred to by the CL.
0 commit comments