@@ -12,76 +12,14 @@ import (
12
12
"fmt"
13
13
"log"
14
14
"os"
15
- "path"
16
15
"path/filepath"
17
16
"regexp"
18
17
"runtime"
19
- "strings"
20
18
"time"
21
-
22
- "golang.org/x/build/maintner"
23
- "golang.org/x/build/repos"
24
19
)
25
20
26
21
var verbose = flag .Bool ("v" , false , "print verbose logging" )
27
22
28
- // change is a change that was noted via a RELNOTE= comment.
29
- type change struct {
30
- CL * maintner.GerritCL
31
- Note string // the part after RELNOTE=
32
- Issue * maintner.GitHubIssue
33
- }
34
-
35
- func (c change ) ID () string {
36
- switch {
37
- default :
38
- panic ("invalid change" )
39
- case c .CL != nil :
40
- return fmt .Sprintf ("CL %d" , c .CL .Number )
41
- case c .Issue != nil :
42
- return fmt .Sprintf ("https://go.dev/issue/%d" , c .Issue .Number )
43
- }
44
- }
45
-
46
- func (c change ) URL () string {
47
- switch {
48
- default :
49
- panic ("invalid change" )
50
- case c .CL != nil :
51
- return fmt .Sprint ("https://go.dev/cl/" , c .CL .Number )
52
- case c .Issue != nil :
53
- return fmt .Sprint ("https://go.dev/issue/" , c .Issue .Number )
54
- }
55
- }
56
-
57
- func (c change ) Subject () string {
58
- switch {
59
- default :
60
- panic ("invalid change" )
61
- case c .CL != nil :
62
- subj := c .CL .Subject ()
63
- subj = strings .TrimPrefix (subj , clPackage (c .CL )+ ":" )
64
- return strings .TrimSpace (subj )
65
- case c .Issue != nil :
66
- return issueSubject (c .Issue )
67
- }
68
- }
69
-
70
- func (c change ) TextLine () string {
71
- switch {
72
- default :
73
- panic ("invalid change" )
74
- case c .CL != nil :
75
- subj := c .CL .Subject ()
76
- if c .Note != "yes" && c .Note != "y" {
77
- subj += "; " + c .Note
78
- }
79
- return subj
80
- case c .Issue != nil :
81
- return issueSubject (c .Issue )
82
- }
83
- }
84
-
85
23
func usage () {
86
24
out := flag .CommandLine .Output ()
87
25
fmt .Fprintf (out , "usage:\n " )
@@ -141,52 +79,3 @@ func main() {
141
79
log .Fatal ("missing subcommand" )
142
80
}
143
81
}
144
-
145
- // packagePrefix returns the package prefix at the start of s.
146
- // For example packagePrefix("net/http: add HTTP 5 support") == "net/http".
147
- // If there's no package prefix, packagePrefix returns "".
148
- func packagePrefix (s string ) string {
149
- i := strings .Index (s , ":" )
150
- if i < 0 {
151
- return ""
152
- }
153
- s = s [:i ]
154
- if strings .Trim (s , "abcdefghijklmnopqrstuvwxyz0123456789/" ) != "" {
155
- return ""
156
- }
157
- return s
158
- }
159
-
160
- // clPackage returns the package import path from the CL's commit message,
161
- // or "??" if it's formatted unconventionally.
162
- func clPackage (cl * maintner.GerritCL ) string {
163
- pkg := packagePrefix (cl .Subject ())
164
- if pkg == "" {
165
- return "??"
166
- }
167
- if r := repos .ByGerritProject [cl .Project .Project ()]; r == nil {
168
- return "??"
169
- } else {
170
- pkg = path .Join (r .ImportPath , pkg )
171
- }
172
- return pkg
173
- }
174
-
175
- // issuePackage returns the package import path from the issue's title,
176
- // or "??" if it's formatted unconventionally.
177
- func issuePackage (issue * maintner.GitHubIssue ) string {
178
- pkg := packagePrefix (issue .Title )
179
- if pkg == "" {
180
- return "??"
181
- }
182
- return pkg
183
- }
184
-
185
- // issueSubject returns the issue's title with the package prefix removed.
186
- func issueSubject (issue * maintner.GitHubIssue ) string {
187
- pkg := packagePrefix (issue .Title )
188
- if pkg == "" {
189
- return issue .Title
190
- }
191
- return strings .TrimSpace (strings .TrimPrefix (issue .Title , pkg + ":" ))
192
- }
0 commit comments