@@ -64,6 +64,22 @@ type GerritClient interface {
64
64
SetHashtags (ctx context.Context , changeID string , hashtags gerrit.HashtagsInput ) error
65
65
// GetChange gets information about a specific change.
66
66
GetChange (ctx context.Context , changeID string , opts ... gerrit.QueryChangesOpt ) (* gerrit.ChangeInfo , error )
67
+ // SubmitChange submits a specific change.
68
+ SubmitChange (ctx context.Context , changeID string ) (gerrit.ChangeInfo , error )
69
+ // CreateCherryPick creates a cherry-pick change. If there are no merge
70
+ // conflicts, it starts trybots. If commitMessage is provided, the commit
71
+ // message is updated, otherwise it is taken from the original change.
72
+ // Reviewers are taken from the original change.
73
+ CreateCherryPick (ctx context.Context , changeID string , branch string , commitMessage string ) (_ gerrit.ChangeInfo , conflicts bool , _ error )
74
+ // RebaseChange rebases a change onto a base revision. If revision is empty,
75
+ // the change is rebased directly on top of the target branch.
76
+ RebaseChange (ctx context.Context , changeID string , revision string ) (gerrit.ChangeInfo , error )
77
+ // MoveChange moves a change onto a new branch.
78
+ MoveChange (ctx context.Context , changeID string , branch string , keepAllVotes bool ) (gerrit.ChangeInfo , error )
79
+ // GetRevisionActions retrieves revision actions.
80
+ GetRevisionActions (ctx context.Context , changeID , revision string ) (map [string ]* gerrit.ActionInfo , error )
81
+ // GetCommitMessage retrieves the commit message for a change.
82
+ GetCommitMessage (ctx context.Context , changeID string ) (string , error )
67
83
}
68
84
69
85
type RealGerritClient struct {
@@ -311,3 +327,46 @@ func (c *RealGerritClient) SetHashtags(ctx context.Context, changeID string, has
311
327
_ , err := c .Client .SetHashtags (ctx , changeID , hashtags )
312
328
return err
313
329
}
330
+
331
+ func (c * RealGerritClient ) SubmitChange (ctx context.Context , changeID string ) (gerrit.ChangeInfo , error ) {
332
+ return c .Client .SubmitChange (ctx , changeID )
333
+ }
334
+
335
+ func (c * RealGerritClient ) CreateCherryPick (ctx context.Context , changeID string , branch string , commitMessage string ) (gerrit.ChangeInfo , bool , error ) {
336
+ cpi := gerrit.CherryPickInput {Destination : branch , KeepReviewers : true , AllowConflicts : true , Message : commitMessage }
337
+ ci , err := c .Client .CherryPickRevision (ctx , changeID , "current" , cpi )
338
+ if err != nil {
339
+ return gerrit.ChangeInfo {}, false , err
340
+ }
341
+ if ci .ContainsGitConflicts {
342
+ return ci , true , nil
343
+ }
344
+ if err := c .Client .SetReview (ctx , ci .ID , "current" , gerrit.ReviewInput {
345
+ Labels : map [string ]int {
346
+ "Commit-Queue" : 1 ,
347
+ },
348
+ }); err != nil {
349
+ return gerrit.ChangeInfo {}, false , err
350
+ }
351
+ return ci , false , nil
352
+ }
353
+
354
+ func (c * RealGerritClient ) MoveChange (ctx context.Context , changeID string , branch string , keepAllVotes bool ) (gerrit.ChangeInfo , error ) {
355
+ return c .Client .MoveChange (ctx , changeID , gerrit.MoveInput {DestinationBranch : branch , KeepAllVotes : keepAllVotes })
356
+ }
357
+
358
+ func (c * RealGerritClient ) RebaseChange (ctx context.Context , changeID string , base string ) (gerrit.ChangeInfo , error ) {
359
+ return c .Client .RebaseChange (ctx , changeID , gerrit.RebaseInput {Base : base , AllowConflicts : true })
360
+ }
361
+
362
+ func (c * RealGerritClient ) GetRevisionActions (ctx context.Context , changeID , revision string ) (map [string ]* gerrit.ActionInfo , error ) {
363
+ return c .Client .GetRevisionActions (ctx , changeID , revision )
364
+ }
365
+
366
+ func (c * RealGerritClient ) GetCommitMessage (ctx context.Context , changeID string ) (string , error ) {
367
+ cmi , err := c .Client .GetCommitMessage (ctx , changeID )
368
+ if err != nil {
369
+ return "" , err
370
+ }
371
+ return cmi .FullMessage , nil
372
+ }
0 commit comments