@@ -35,24 +35,32 @@ type TagXReposTasks struct {
35
35
CreateBuildlet func (context.Context , string ) (buildlet.RemoteClient , error )
36
36
LatestGoBinaries func (context.Context ) (string , error )
37
37
DashboardURL string
38
- ApproveAction func (* wf.TaskContext ) error
39
38
}
40
39
41
40
func (x * TagXReposTasks ) NewDefinition () * wf.Definition {
42
41
wd := wf .New ()
42
+ reviewers := wf .Param (wd , reviewersParam )
43
43
repos := wf .Task0 (wd , "Select repositories" , x .SelectRepos )
44
- wf .Expand1 (wd , "Create plan" , x .BuildPlan , repos )
44
+ wf .Expand2 (wd , "Create plan" , x .BuildPlan , repos , reviewers )
45
45
return wd
46
46
}
47
47
48
48
func (x * TagXReposTasks ) NewSingleDefinition () * wf.Definition {
49
49
wd := wf .New ()
50
+ reviewers := wf .Param (wd , reviewersParam )
50
51
repos := wf .Task0 (wd , "Load all repositories" , x .SelectRepos )
51
52
name := wf .Param (wd , wf.ParamDef [string ]{Name : "Repository name" , Example : "tools" })
52
- wf .Expand2 (wd , "Create single-repo plan" , x .BuildSingleRepoPlan , repos , name )
53
+ wf .Expand3 (wd , "Create single-repo plan" , x .BuildSingleRepoPlan , repos , name , reviewers )
53
54
return wd
54
55
}
55
56
57
+ var reviewersParam = wf.ParamDef [[]string ]{
58
+ Name : "Reviewer usernames (optional)" ,
59
+ ParamType : wf .SliceShort ,
60
+ Doc : `Send code reviews to these users.` ,
61
+ Example : "heschi" ,
62
+ }
63
+
56
64
// TagRepo contains information about a repo that can be tagged.
57
65
type TagRepo struct {
58
66
Name string // Gerrit project name, e.g. "tools".
@@ -222,7 +230,7 @@ func checkCycles1(reposByModule map[string]TagRepo, repo TagRepo, stack []string
222
230
}
223
231
224
232
// BuildPlan adds the tasks needed to update repos to wd.
225
- func (x * TagXReposTasks ) BuildPlan (wd * wf.Definition , repos []TagRepo ) error {
233
+ func (x * TagXReposTasks ) BuildPlan (wd * wf.Definition , repos []TagRepo , reviewers [] string ) error {
226
234
// repo.ModPath to the wf.Value produced by updating it.
227
235
updated := map [string ]wf.Value [TagRepo ]{}
228
236
@@ -234,7 +242,7 @@ func (x *TagXReposTasks) BuildPlan(wd *wf.Definition, repos []TagRepo) error {
234
242
if _ , ok := updated [repo .ModPath ]; ok {
235
243
continue
236
244
}
237
- dep , ok := x .planRepo (wd , repo , updated )
245
+ dep , ok := x .planRepo (wd , repo , updated , reviewers )
238
246
if ! ok {
239
247
continue
240
248
}
@@ -261,7 +269,7 @@ func (x *TagXReposTasks) BuildPlan(wd *wf.Definition, repos []TagRepo) error {
261
269
return nil
262
270
}
263
271
264
- func (x * TagXReposTasks ) BuildSingleRepoPlan (wd * wf.Definition , repoSlice []TagRepo , name string ) error {
272
+ func (x * TagXReposTasks ) BuildSingleRepoPlan (wd * wf.Definition , repoSlice []TagRepo , name string , reviewers [] string ) error {
265
273
repos := map [string ]TagRepo {}
266
274
updatedRepos := map [string ]wf.Value [TagRepo ]{}
267
275
for _ , r := range repoSlice {
@@ -275,7 +283,7 @@ func (x *TagXReposTasks) BuildSingleRepoPlan(wd *wf.Definition, repoSlice []TagR
275
283
if ! ok {
276
284
return fmt .Errorf ("no repository %q" , name )
277
285
}
278
- tagged , ok := x .planRepo (wd , repo , updatedRepos )
286
+ tagged , ok := x .planRepo (wd , repo , updatedRepos , reviewers )
279
287
if ! ok {
280
288
return fmt .Errorf ("%q doesn't have all of its dependencies (%q)" , repo .Name , repo .Deps )
281
289
}
@@ -286,7 +294,7 @@ func (x *TagXReposTasks) BuildSingleRepoPlan(wd *wf.Definition, repoSlice []TagR
286
294
// planRepo adds tasks to wf to update and tag repo. It returns a Value
287
295
// containing the tagged repository's information, or nil, false if its
288
296
// dependencies haven't been planned yet.
289
- func (x * TagXReposTasks ) planRepo (wd * wf.Definition , repo TagRepo , updated map [string ]wf.Value [TagRepo ]) (_ wf.Value [TagRepo ], ready bool ) {
297
+ func (x * TagXReposTasks ) planRepo (wd * wf.Definition , repo TagRepo , updated map [string ]wf.Value [TagRepo ], reviewers [] string ) (_ wf.Value [TagRepo ], ready bool ) {
290
298
var deps []wf.Value [TagRepo ]
291
299
for _ , repoDeps := range repo .Deps {
292
300
if dep , ok := updated [repoDeps ]; ok {
@@ -303,7 +311,7 @@ func (x *TagXReposTasks) planRepo(wd *wf.Definition, repo TagRepo, updated map[s
303
311
tagCommit = wf .Task2 (wd , "read branch head" , x .Gerrit .ReadBranchHead , repoName , branch )
304
312
} else {
305
313
gomod := wf .Task3 (wd , "generate updated go.mod" , x .UpdateGoMod , wf .Const (repo ), wf .Slice (deps ... ), branch )
306
- cl := wf .Task2 (wd , "mail updated go.mod" , x .MailGoMod , repoName , gomod )
314
+ cl := wf .Task3 (wd , "mail updated go.mod" , x .MailGoMod , repoName , gomod , wf . Const ( reviewers ) )
307
315
tagCommit = wf .Task3 (wd , "wait for submit" , x .AwaitGoMod , cl , repoName , branch )
308
316
}
309
317
greenCommit := wf .Task2 (wd , "wait for green post-submit" , x .AwaitGreen , wf .Const (repo ), tagCommit )
@@ -457,7 +465,7 @@ func LatestGoBinaries(ctx context.Context) (string, error) {
457
465
return "" , fmt .Errorf ("no linux-amd64??" )
458
466
}
459
467
460
- func (x * TagXReposTasks ) MailGoMod (ctx * wf.TaskContext , repo string , files map [string ]string ) (string , error ) {
468
+ func (x * TagXReposTasks ) MailGoMod (ctx * wf.TaskContext , repo string , files map [string ]string , reviewers [] string ) (string , error ) {
461
469
const subject = `go.mod: update golang.org/x dependencies
462
470
463
471
Update golang.org/x dependencies to their latest tagged versions.
@@ -469,7 +477,7 @@ will be tagged with its next minor version.
469
477
Project : repo ,
470
478
Branch : "master" ,
471
479
Subject : subject ,
472
- }, nil , files )
480
+ }, reviewers , files )
473
481
}
474
482
475
483
func (x * TagXReposTasks ) AwaitGoMod (ctx * wf.TaskContext , changeID , repo , branch string ) (string , error ) {
@@ -658,11 +666,7 @@ func (x *TagXReposTasks) MaybeTag(ctx *wf.TaskContext, repo TagRepo, commit stri
658
666
return TagRepo {}, fmt .Errorf ("couldn't pick next version for %v: %v" , repo .Name , err )
659
667
}
660
668
661
- // TODO(heschi): delete after first couple uses
662
- ctx .Printf ("Waiting for approval to tag %v at %v as %v" , repo .Name , commit , repo .Version )
663
- if err := x .ApproveAction (ctx ); err != nil {
664
- return TagRepo {}, err
665
- }
669
+ ctx .Printf ("Tagging %v at %v as %v" , repo .Name , commit , repo .Version )
666
670
return repo , x .Gerrit .Tag (ctx , repo .Name , repo .Version , commit )
667
671
}
668
672
0 commit comments