codereview

package
v0.0.0-...-2b80fd9 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The tag that SkCQ will apply to all comments published by it.
	AutogeneratedCommentTag = "autogenerated:skcq"

	// The number of changes to search in Gerrit for CQ/dry-runs.
	GerritOpenChangesNum = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeReview

type CodeReview interface {

	// AddComments adds a comment to the specified change using the
	// AutogeneratedCommentTag.
	AddComment(ctx context.Context, ci *gerrit.ChangeInfo, comment string, notify NotifyOption, notifyReason string) error

	// GetChangeRef returns the change's ref string. A change ref has the format
	// refs/changes/X/Y/Z where X is the last two digits of the change number,
	// Y is the entire change number, and Z is the patch set.
	// Eg: For change 401222 and patchset 140, the change ref would be:
	//     refs/changes/22/401222/140
	GetChangeRef(ci *gerrit.ChangeInfo) string

	// GetCommitAuthor retrieves the author of the commit that corresponds to
	// the patch identified by issue and revision.
	GetCommitAuthor(ctx context.Context, issue int64, revision string) (string, error)

	// GetCommitMessage returns the commit msg of this change. Note: this returns
	// the commit msg on the latest patchset.
	GetCommitMessage(ctx context.Context, issue int64) (string, error)

	// GetEarliestEquialentPatchSetID returns the earliest patchset that is
	// functionally equivalent to the latest patchset (i.e. not a CODE_CHANGE
	// patchset).
	GetEarliestEquivalentPatchSetID(ci *gerrit.ChangeInfo) int64

	// GetEquivalentPatchSetIDs returns a slice of patchsetIDs that are
	// functionally equivalent to the specified patchset (i.e. not a
	// CODE_CHANGE patchset).
	GetEquivalentPatchSetIDs(ci *gerrit.ChangeInfo, patchsetID int64) []int64

	// GetFileNames returns all the files modified (A/D/M) by this change.
	GetFileNames(ctx context.Context, ci *gerrit.ChangeInfo) ([]string, error)

	// GetIssueProperties returns a fully filled in gerrit.ChangeInfo object.
	GetIssueProperties(ctx context.Context, issue int64) (*gerrit.ChangeInfo, error)

	// GetLatestPatchSetID returns the patchsetID of the latest patchset.
	GetLatestPatchSetID(ci *gerrit.ChangeInfo) int64

	// GetSubmittedTogether returns the list of changes that will be submitted
	// at the same time as the given change. Note: The specified change will not
	// be included in the returned slice of changes.
	// The returned ChangeInfo objects are fully filled in.
	GetSubmittedTogether(ctx context.Context, ci *gerrit.ChangeInfo) ([]*gerrit.ChangeInfo, error)

	// IsCQ returns whether the specified change is a CQ run.
	IsCQ(ctx context.Context, ci *gerrit.ChangeInfo) bool

	// IsDryRun returns whether the specified change is a dry run.
	IsDryRun(ctx context.Context, ci *gerrit.ChangeInfo) bool

	// RemoveFromCQ removes all CQ+1/CQ+2 votes on a change and updates the
	// change with the specified message.
	RemoveFromCQ(ctx context.Context, ci *gerrit.ChangeInfo, comment string, notifyReason string)

	// Search returns open changes with CQ+2 or CQ+1 votes set.
	// Note: This returns gerrit.ChangeInfo that are incomplete. Call
	// GetIssueProperties to populate them.
	Search(ctx context.Context) ([]*gerrit.ChangeInfo, error)

	// SetReadyForReview publishes the specified change. i.e. it sets it from
	// WIP to ready for reaview.
	SetReadyForReview(ctx context.Context, ci *gerrit.ChangeInfo) error

	// Submit submits the specifed change.
	Submit(ctx context.Context, ci *gerrit.ChangeInfo) error

	// Url returns the url of the issue identified by issueID or the
	// base URL of the Gerrit instance if issueID is 0.
	Url(issueID int64) string

	// GetRepoUrl returns the url of the Googlesource repo.
	GetRepoUrl(ci *gerrit.ChangeInfo) string

	// GetCQVoters returns all CQ label voters.
	GetCQVoters(ctx context.Context, ci *gerrit.ChangeInfo) []string
}

Interface to abstract out SkCQ communications with gerrit client and provide utility methods.

func NewGerrit

func NewGerrit(httpClient *http.Client, cfg *gerrit.Config, gerritURL string) (CodeReview, error)

NewGerrit returns a gerritCodeReview instance.

type NotifyOption

type NotifyOption string

NotifyOption are the different notification options supported by SkCQ.

const NotifyNone NotifyOption = "NONE"
const NotifyOwnerReviewersTriggerers NotifyOption = "OWNER_REVIEWERS_TRIGGERERS"
const NotifyOwnerTriggerers NotifyOption = "OWNER_TRIGGERERS"

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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