gerrit

package
v0.0.0-...-d3da680 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package gerrit contains logic for interacting with Gerrit

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthorEmail

func AuthorEmail(ctx context.Context, change *gerritpb.ChangeInfo) (string, error)

AuthorEmail returns the email of the author of the change's current commit.

func CommitMessage

func CommitMessage(ctx context.Context, change *gerritpb.ChangeInfo) (string, error)

CommitMessage returns the commit message of the change

func GetHost

func GetHost(ctx context.Context, rawReviewURL string) (string, error)

GetHost extracts the Gerrit host from the given Gerrit review URL

func HasAutoRevertOffFlagSet

func HasAutoRevertOffFlagSet(ctx context.Context, change *gerritpb.ChangeInfo) (bool, error)

HasAutoRevertOffFlagSet returns whether the change has the flag set to true to prevent auto-revert.

func HasLUCIBisectionComment

func HasLUCIBisectionComment(ctx context.Context, change *gerritpb.ChangeInfo) (bool, error)

HasLUCIBisectionComment returns whether LUCI Bisection has previously commented on the change

func IsOwnedByLUCIBisection

func IsOwnedByLUCIBisection(ctx context.Context, change *gerritpb.ChangeInfo) (bool, error)

IsOwnedByLUCIBisection returns whether the change is owned by LUCI Bisection

func IsRecentSubmit

func IsRecentSubmit(ctx context.Context, change *gerritpb.ChangeInfo, maxAge time.Duration) bool

IsRecentSubmit returns whether the change was submitted recently, as defined by the maximum age duration given relative to now.

func ServiceAccountEmail

func ServiceAccountEmail(ctx context.Context) (string, error)

ServiceAccountEmail is a helper function to get the email address that LUCI Bisection uses to perform Gerrit actions.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the client to communicate with Gerrit It wraps a gerritpb.GerritClient

func NewClient

func NewClient(ctx context.Context, host string) (*Client, error)

NewClient creates a client to communicate with Gerrit

func (*Client) AddComment

func (c *Client) AddComment(ctx context.Context, change *gerritpb.ChangeInfo, message string) (*gerritpb.ReviewResult, error)

AddComment adds the given message as a review comment on a change

func (*Client) CommitRevert

func (c *Client) CommitRevert(ctx context.Context, change *gerritpb.ChangeInfo,
	message string, ccEmails []string) (*gerritpb.ReviewResult, error)

CommitRevert bot-commits the revert change. The change must be a pure revert; if not, this function does not attempt to commit the change and returns an error.

func (*Client) CreateRevert

func (c *Client) CreateRevert(ctx context.Context, change *gerritpb.ChangeInfo, message string) (*gerritpb.ChangeInfo, error)

CreateRevert creates a revert change in Gerrit for the specified change.

func (*Client) GetChange

func (c *Client) GetChange(ctx context.Context, project string, commitID string) (*gerritpb.ChangeInfo, error)

GetChange gets the corresponding change info given the commit ID. This function returns an error if none or more than 1 changes are returned by Gerrit.

func (*Client) GetReverts

func (c *Client) GetReverts(ctx context.Context, change *gerritpb.ChangeInfo) ([]*gerritpb.ChangeInfo, error)

GetReverts gets the corresponding revert(s) for the given change.

func (*Client) HasDependency

func (c *Client) HasDependency(ctx context.Context, change *gerritpb.ChangeInfo) (bool, error)

HasDependency returns whether the change has another merged change depending on it

func (*Client) Host

func (c *Client) Host(ctx context.Context) string

Host returns the Gerrit host string

func (*Client) RefetchChange

func (c *Client) RefetchChange(ctx context.Context, change *gerritpb.ChangeInfo) (*gerritpb.ChangeInfo, error)

RefetchChange queries Gerrit for the given change, and returns the latest state of the change

func (*Client) SendForReview

func (c *Client) SendForReview(ctx context.Context, change *gerritpb.ChangeInfo, message string,
	reviewerEmails []string, ccEmails []string) (*gerritpb.ReviewResult, error)

SendForReview adds the emails as reviewers for the change, and sets the change to be ready for review

type MockedClient

type MockedClient struct {
	Client *gerritpb.MockGerritClient
	Ctx    context.Context
}

MockedClient is a mocked Gerrit client for testing. It wraps a gerritpb.MockGerritClient and a context with the mocked client

func NewMockedClient

func NewMockedClient(ctx context.Context, ctl *gomock.Controller) *MockedClient

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL