gerrit

package
v0.0.0-...-52c2931 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: BSD-3-Clause Imports: 29 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// TimeFormat is the timestamp format used by the Gerrit API.
	TimeFormat = "2006-01-02 15:04:05.999999"
	// GerritSkiaURL is the URL of Skia's Gerrit instance.
	GerritSkiaURL = "https://skia-review.googlesource.com"

	// AuthScope is the auth scope needed to use the Gerrit API.
	AuthScope = auth.ScopeGerrit

	// ChangeStatusAbandoned indicates the change is abandoned.
	ChangeStatusAbandoned = "ABANDONED"
	// ChangeStatusMerged indicates the change is merged.
	ChangeStatusMerged = "MERGED"
	// ChangeStatusNew indicates the change is new.
	ChangeStatusNew = "NEW"
	// ChangeStatusNew indicates the change is open.
	ChangeStatusOpen = "OPEN"

	// LabelCodeReview is the label used for code review.
	LabelCodeReview = "Code-Review"
	// LabelCodeReviewDisapprove indicates code review disapproval.
	LabelCodeReviewDisapprove = -1
	// LabelCodeReviewNone indicates that the change has not been code reviewed.
	LabelCodeReviewNone = 0
	// LabelCodeReviewApprove indicates code review approval.
	LabelCodeReviewApprove = 1
	// LabelCodeReviewSelfApprove indicates code review self-approval.
	LabelCodeReviewSelfApprove = 2

	// LabelCommitQueue is the label used for the commit queue.
	LabelCommitQueue = "Commit-Queue"
	// LabelCommitQueueNone indicates that the commit queue is not running for
	// this change.
	LabelCommitQueueNone = 0
	// LabelCommitQueueDryRun indicates that the commit queue should run in dry
	// run mode for this change.
	LabelCommitQueueDryRun = 1
	// LabelCommitQueueSubmit indicates that the commit queue should run for
	// this change.
	LabelCommitQueueSubmit = 2

	// LabelAndroidAutoSubmit indicates whether the change should be submitted
	// when it is approved.  For Android hosts only.
	LabelAndroidAutoSubmit = "Autosubmit"
	// LabelAndroidAutoSubmitNone indicates that the change should not be
	// submitted when it is approved.
	LabelAndroidAutoSubmitNone = 0
	// LabelAndroidAutoSubmitSubmit indicates that the change should be
	// submitted when it is approved.
	LabelAndroidAutoSubmitSubmit = 1

	// LabelChromiumAutoSubmit indicates whether the change should be submitted
	// when it is approved.  For Chromium hosts only.
	LabelChromiumAutoSubmit = "Auto-Submit"
	// LabelChromiumAutoSubmitNone indicates that the change should not be
	// submitted when it is approved.
	LabelChromiumAutoSubmitNone = 0
	// LabelChromiumAutoSubmitSubmit indicates that the change should be
	// submitted when it is approved.
	LabelChromiumAutoSubmitSubmit = 1

	// LabelPresubmitReady indicates whether the presubmit checks should run for
	// this change.
	LabelPresubmitReady = "Presubmit-Ready"
	// LabelPresubmitReadyNone indicates that the presubmit checks should not
	// run for this change.
	LabelPresubmitReadyNone = 0
	// LabelPresubmitReadyEnable indicates that the presubmit checks should run
	// for this change.
	LabelPresubmitReadyEnable = 1

	// LabelPresubmitVerified indicates whether the presubmit checks ran
	// successfully for this change.
	LabelPresubmitVerified = "Presubmit-Verified"
	// LabelPresubmitVerifiedRejected indicates that the presubmit checks failed
	// for this change.
	LabelPresubmitVerifiedRejected = -1
	// LabelPresubmitVerifiedRunning indicates that the presubmit checks have
	// not finished for this change.
	LabelPresubmitVerifiedRunning = 0
	// LabelPresubmitVerifiedAccepted indicates that the presubmit checks
	// succeeded for this change.
	LabelPresubmitVerifiedAccepted = 2

	// LabelVerified indicates whether the presubmit checks ran successfully for
	// this change.
	LabelVerified = "Verified"
	// LabelVerifiedRejected indicates that the presubmit checks failed for this
	// change.
	LabelVerifiedRejected = -1
	// LabelVerifiedRunning indicates that the presubmit checks have not
	// finished for this change.
	LabelVerifiedRunning = 0
	// LabelVerifiedAccepted indicates that the presubmit checks succeeded for
	// this change.
	LabelVerifiedAccepted = 1

	// LabelBotCommit indicates self-approval by a trusted bot.
	LabelBotCommit = "Bot-Commit"
	// LabelBotCommitNone indicates that the change is not self-approved by a
	// trusted bot.
	LabelBotCommitNone = 0
	// LabelBotCommitApproved indicates that the change is self-approved by a
	// trusted bot.
	LabelBotCommitApproved = 1

	// URLTmplChange is the template for a change URL.
	URLTmplChange = "/changes/%s/detail?o=ALL_REVISIONS&o=SUBMITTABLE"

	// Kinds of patchsets.
	PatchSetKindMergeFirstParentUpdate = "MERGE_FIRST_PARENT_UPDATE"
	PatchSetKindNoChange               = "NO_CHANGE"
	PatchSetKindNoCodeChange           = "NO_CODE_CHANGE"
	PatchSetKindCodeChange             = "CODE_CHANGE"
	PatchSetKindRework                 = "REWORK"
	PatchSetKindTrivialRebase          = "TRIVIAL_REBASE"

	// ChangeRefPrefix is the prefix used by change refs in Gerrit, which are of
	// this form:
	//
	//  refs/changes/46/4546/1
	//                |  |   |
	//                |  |   +-> Patch set.
	//                |  |
	//                |  +-> Issue ID.
	//                |
	//                +-> Last two digits of Issue ID.
	ChangeRefPrefix = "refs/changes/"

	// ErrCannotRebaseMergeCommits as a substring of an error indicates that we
	// tried to rebase a merge commit.
	ErrCannotRebaseMergeCommits = "Cannot rebase merge commits"

	// ErrMergeConflict as a substring of an error message indicates that a
	// merge conflict occurred.
	ErrMergeConflict = "conflict during merge"

	// ErrUnsubmittedDependend as a substring of an error message indicates
	// that a dependend CL has not been submitted yet.
	ErrUnsubmittedDependend = "Depends on change that was not submitted"

	// ErrEmptyCommit as a substring of an error message indicates that
	// submission was rejected due to an empty commit.
	ErrEmptyCommit = "Change could not be merged because the commit is empty"

	// ErrNoChanges as a substring of an error message indicates that there were
	// no changes to apply. Generally we can ignore this error.
	ErrNoChanges = "no changes were made"

	// Gerrit's magic path for the commit message. See:
	// https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#file-id
	CommitMsgFileName = "/COMMIT_MSG"

	// HTTP header used to enable tracing.
	HeaderTracing = "X-Gerrit-Trace"
)
View Source
const RecipientBCC = "BCC"
View Source
const RecipientCC = "CC"
View Source
const RecipientTo = "TO"

Variables

View Source
var (
	// ConfigAndroid is the configuration for Android Gerrit hosts.
	ConfigAndroid = &Config{
		SelfApproveLabels: map[string]int{
			LabelCodeReview: LabelCodeReviewSelfApprove,
		},
		HasCq: true,
		SetCqLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitSubmit,
			LabelPresubmitReady:    LabelPresubmitReadyEnable,
		},
		SetDryRunLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitNone,
			LabelPresubmitReady:    LabelPresubmitReadyEnable,
		},
		NoCqLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitNone,
			LabelPresubmitReady:    LabelPresubmitReadyNone,
		},
		CqActiveLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitSubmit,
			LabelPresubmitReady:    LabelPresubmitReadyEnable,
		},
		CqSuccessLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitSubmit,
			LabelPresubmitVerified: LabelPresubmitVerifiedAccepted,
		},
		CqFailureLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitSubmit,
			LabelPresubmitVerified: LabelPresubmitVerifiedRejected,
		},
		CqLabelsUnsetOnCompletion: true,
		DryRunActiveLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitNone,
			LabelPresubmitReady:    LabelPresubmitReadyEnable,
		},
		DryRunSuccessLabels: map[string]int{
			LabelPresubmitVerified: LabelPresubmitVerifiedAccepted,
		},
		DryRunFailureLabels: map[string]int{
			LabelPresubmitVerified: LabelPresubmitVerifiedRejected,
		},
		DryRunUsesTryjobResults: false,
	}

	// ConfigAndroidNoCR is the configuration for Android Gerrit hosts where
	// the service account does not have CR+2 access.
	ConfigAndroidNoCR = &Config{
		SelfApproveLabels: map[string]int{
			LabelCodeReview: LabelCodeReviewNone,
		},
		HasCq: true,
		SetCqLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitSubmit,
			LabelPresubmitReady:    LabelPresubmitReadyEnable,
		},
		SetDryRunLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitNone,
			LabelPresubmitReady:    LabelPresubmitReadyEnable,
		},
		NoCqLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitNone,
			LabelPresubmitReady:    LabelPresubmitReadyNone,
		},
		CqActiveLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitSubmit,
			LabelPresubmitReady:    LabelPresubmitReadyEnable,
		},
		CqSuccessLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitSubmit,
			LabelPresubmitVerified: LabelPresubmitVerifiedAccepted,
		},
		CqFailureLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitSubmit,
			LabelPresubmitVerified: LabelPresubmitVerifiedRejected,
		},
		CqLabelsUnsetOnCompletion: true,
		DryRunActiveLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitNone,
			LabelPresubmitReady:    LabelPresubmitReadyEnable,
		},
		DryRunSuccessLabels: map[string]int{
			LabelPresubmitVerified: LabelPresubmitVerifiedAccepted,
		},
		DryRunFailureLabels: map[string]int{
			LabelPresubmitVerified: LabelPresubmitVerifiedRejected,
		},
		DryRunUsesTryjobResults: false,
	}

	// ConfigAndroidNoCRNoPR is the configuration for Android Gerrit hosts where
	// the service account does not have CR+2 and PR+1 access.
	ConfigAndroidNoCRNoPR = &Config{
		SelfApproveLabels: map[string]int{
			LabelCodeReview: LabelCodeReviewNone,
		},
		HasCq: true,
		SetCqLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitSubmit,
			LabelPresubmitReady:    LabelPresubmitReadyNone,
		},
		SetDryRunLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitNone,
			LabelPresubmitReady:    LabelPresubmitReadyNone,
		},
		NoCqLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitNone,
			LabelPresubmitReady:    LabelPresubmitReadyNone,
		},
		CqActiveLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitSubmit,
			LabelPresubmitReady:    LabelPresubmitReadyEnable,
		},
		CqSuccessLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitSubmit,
			LabelPresubmitVerified: LabelPresubmitVerifiedAccepted,
		},
		CqFailureLabels: map[string]int{
			LabelAndroidAutoSubmit: LabelAndroidAutoSubmitSubmit,
			LabelPresubmitVerified: LabelPresubmitVerifiedRejected,
		},
		CqLabelsUnsetOnCompletion: true,
		DryRunActiveLabels:        map[string]int{},
		DryRunSuccessLabels: map[string]int{
			LabelPresubmitVerified: LabelPresubmitVerifiedAccepted,
		},
		DryRunFailureLabels: map[string]int{
			LabelPresubmitVerified: LabelPresubmitVerifiedRejected,
		},
		DryRunUsesTryjobResults: false,
	}

	// ConfigANGLE is the configuration for ANGLE Gerrit hosts.
	ConfigANGLE = &Config{
		SelfApproveLabels: map[string]int{
			LabelCodeReview: LabelCodeReviewSelfApprove,
		},
		HasCq: true,
		SetCqLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueSubmit,
		},
		SetDryRunLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueDryRun,
		},
		NoCqLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueNone,
		},
		CqActiveLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueSubmit,
		},
		CqSuccessLabels:           map[string]int{},
		CqFailureLabels:           map[string]int{},
		CqLabelsUnsetOnCompletion: true,
		DryRunActiveLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueDryRun,
		},
		DryRunSuccessLabels:     map[string]int{},
		DryRunFailureLabels:     map[string]int{},
		DryRunUsesTryjobResults: true,
	}

	// ConfigChromium is the configuration for Chromium Gerrit hosts.
	ConfigChromium = &Config{
		SelfApproveLabels: map[string]int{
			LabelCodeReview: LabelCodeReviewApprove,
		},
		HasCq: true,
		SetCqLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueSubmit,
		},
		SetDryRunLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueDryRun,
		},
		NoCqLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueNone,
		},
		CqActiveLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueSubmit,
		},
		CqSuccessLabels:           map[string]int{},
		CqFailureLabels:           map[string]int{},
		CqLabelsUnsetOnCompletion: true,
		DryRunActiveLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueDryRun,
		},
		DryRunSuccessLabels:     map[string]int{},
		DryRunFailureLabels:     map[string]int{},
		DryRunUsesTryjobResults: true,
	}

	// ConfigChromiumBotCommit is the configuration for Chromium Gerrit hosts
	// which use the Bot-Commit label instead of Code-Review.
	ConfigChromiumBotCommit = &Config{
		SelfApproveLabels: map[string]int{
			LabelBotCommit: LabelBotCommitApproved,
		},
		HasCq: true,
		SetCqLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueSubmit,
			LabelBotCommit:   LabelBotCommitApproved,
		},
		SetDryRunLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueDryRun,
			LabelBotCommit:   LabelBotCommitApproved,
		},
		NoCqLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueNone,
		},
		CqActiveLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueSubmit,
		},
		CqSuccessLabels:           map[string]int{},
		CqFailureLabels:           map[string]int{},
		CqLabelsUnsetOnCompletion: true,
		DryRunActiveLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueDryRun,
		},
		DryRunSuccessLabels:     map[string]int{},
		DryRunFailureLabels:     map[string]int{},
		DryRunUsesTryjobResults: true,
	}

	// ConfigChromiumNoCR is the configuration for Chromium Gerrit hosts
	// where the service account is not allowed to approve its own changes.
	ConfigChromiumNoCR = &Config{
		SelfApproveLabels: map[string]int{},
		HasCq:             true,
		SetCqLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueSubmit,
		},
		SetDryRunLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueDryRun,
		},
		NoCqLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueNone,
		},
		CqActiveLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueSubmit,
		},
		CqSuccessLabels:           map[string]int{},
		CqFailureLabels:           map[string]int{},
		CqLabelsUnsetOnCompletion: true,
		DryRunActiveLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueDryRun,
		},
		DryRunSuccessLabels:     map[string]int{},
		DryRunFailureLabels:     map[string]int{},
		DryRunUsesTryjobResults: true,
	}

	// ConfigChromiumNoCQ is the configuration for Chromium Gerrit hosts which
	// have no commit queue.
	ConfigChromiumNoCQ = &Config{
		SelfApproveLabels: map[string]int{
			LabelCodeReview: LabelCodeReviewApprove,
		},
		HasCq:           false,
		SetCqLabels:     map[string]int{},
		SetDryRunLabels: map[string]int{},
		NoCqLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueNone,
		},
		CqActiveLabels:            map[string]int{},
		CqSuccessLabels:           map[string]int{},
		CqFailureLabels:           map[string]int{},
		CqLabelsUnsetOnCompletion: true,
		DryRunActiveLabels:        map[string]int{},
		DryRunSuccessLabels:       map[string]int{},
		DryRunFailureLabels:       map[string]int{},
		DryRunUsesTryjobResults:   false,
	}

	// ConfigChromiumBotCommitNoCQ is the configuration for Chromium Gerrit
	// hosts which have no commit queue.
	ConfigChromiumBotCommitNoCQ = &Config{
		SelfApproveLabels: map[string]int{
			LabelBotCommit: LabelBotCommitApproved,
		},
		HasCq:           false,
		SetCqLabels:     map[string]int{},
		SetDryRunLabels: map[string]int{},
		NoCqLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueNone,
		},
		CqActiveLabels:            map[string]int{},
		CqSuccessLabels:           map[string]int{},
		CqFailureLabels:           map[string]int{},
		CqLabelsUnsetOnCompletion: true,
		DryRunActiveLabels:        map[string]int{},
		DryRunSuccessLabels:       map[string]int{},
		DryRunFailureLabels:       map[string]int{},
		DryRunUsesTryjobResults:   false,
	}

	// ConfigLibAssistant is the configuration for LibAssistant Gerrit hosts.
	ConfigLibAssistant = &Config{
		SelfApproveLabels: map[string]int{
			LabelCodeReview: LabelCodeReviewSelfApprove,
		},
		HasCq: true,
		SetCqLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueSubmit,
		},
		SetDryRunLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueDryRun,
		},
		NoCqLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueNone,
		},
		CqActiveLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueSubmit,
		},
		CqSuccessLabels: map[string]int{
			LabelVerified: LabelVerifiedAccepted,
		},
		CqFailureLabels: map[string]int{
			LabelVerified: LabelVerifiedRejected,
		},
		CqLabelsUnsetOnCompletion: false,
		DryRunActiveLabels: map[string]int{
			LabelCommitQueue: LabelCommitQueueDryRun,
		},
		DryRunSuccessLabels: map[string]int{
			LabelVerified: LabelVerifiedAccepted,
		},
		DryRunFailureLabels: map[string]int{
			LabelVerified: LabelVerifiedRejected,
		},
		DryRunUsesTryjobResults: false,
	}
)
View Source
var (
	// ErrNotFound indicates that the requested item was not found.
	ErrNotFound = errors.New("Requested item was not found")

	// ErrBothChangeAndCommitID indicates that both commit and changeID were set.
	ErrBothChangeAndCommitID = errors.New("commit and change ID cannot both be set")
)

AllFileInfoStatus is all valid values of type FileInfoStatus.

View Source
var (
	// ErrEmptyChange indicates that a change, if it were to be made, would be
	// empty (i.e. have no modified files).
	ErrEmptyChange = errors.New("resultant change would be empty")
)

Functions

func ContainsAny

func ContainsAny(id int64, changes []*ChangeInfo) bool

ContainsAny returns true if the provided ChangeInfo slice contains any change with the same issueID as id.

func DefaultGitCookiesPath

func DefaultGitCookiesPath() string

DefaultGitCookiesPath returns the default cookie file. The return value can be used as the input to NewGerrit. If it cannot be retrieved an error will be logged and the empty string is returned.

func EditChange

func EditChange(ctx context.Context, g GerritInterface, ci *ChangeInfo, fn func(context.Context, GerritInterface, *ChangeInfo) error) (rvErr error)

EditChange is a helper for creating a new patch set on an existing Change. Pass in a function which creates and modifies a ChangeEdit, and the result will be automatically published as a new patch set, or in the case of failure, reverted.

func FullChangeId

func FullChangeId(ci *ChangeInfo) string

FullChangeId returns the most specific representation of the specified change. See https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#change-id

func GitCookieAuthDaemonPath

func GitCookieAuthDaemonPath() (string, error)

GitCookieAuthDaemonPath returns the default path that git_cookie_authdaemon writes to. See infra/git_cookie_authdaemon

func MergeLabels

func MergeLabels(a, b map[string]int) map[string]int

MergeLabels returns a new map containing both sets of labels. Labels from the second set overwrite matching labels from the first.

func ParseChangeId

func ParseChangeId(msg string) (string, error)

ParseChangeId parses the change ID out of the given commit message.

func SetLabel

func SetLabel(ci *ChangeInfo, key string, value int)

SetLabel sets the given label on the ChangeInfo.

func SetLabels

func SetLabels(ci *ChangeInfo, labels map[string]int)

SetLabels sets the given labels on the ChangeInfo.

func UnsetLabel

func UnsetLabel(ci *ChangeInfo, key string, value int)

UnsetLabel unsets the given label on the ChangeInfo.

func UnsetLabels

func UnsetLabels(ci *ChangeInfo, labels map[string]int)

UnsetLabels unsets the given labels on the ChangeInfo.

Types

type AccountDetails

type AccountDetails struct {
	AccountId int64  `json:"_account_id"`
	Name      string `json:"name"`
	Email     string `json:"email"`
	UserName  string `json:"username"`
}

AccountDetails provides details about an account in Gerrit.

type AttentionSetInput

type AttentionSetInput struct {
	User   string `json:"user"`
	Reason string `json:"reason"`
}

type ChangeInfo

type ChangeInfo struct {
	Id              string              `json:"id"`
	Insertions      int                 `json:"insertions"`
	Deletions       int                 `json:"deletions"`
	Created         time.Time           `json:"-"`
	CreatedString   string              `json:"created"`
	Updated         time.Time           `json:"-"`
	UpdatedString   string              `json:"updated"`
	Submitted       time.Time           `json:"-"`
	SubmittedString string              `json:"submitted"`
	Project         string              `json:"project"`
	ChangeId        string              `json:"change_id"`
	Subject         string              `json:"subject"`
	Branch          string              `json:"branch"`
	Committed       bool                `json:"committed"`
	Messages        []ChangeInfoMessage `json:"messages"`
	Reviewers       struct {
		CC       []*Person `json:"CC"`
		Reviewer []*Person `json:"REVIEWER"`
	} `json:"reviewers"`
	Revisions            map[string]*Revision   `json:"revisions"`
	Patchsets            []*Revision            `json:"-"`
	MoreChanges          bool                   `json:"_more_changes"`
	Issue                int64                  `json:"_number"`
	Labels               map[string]*LabelEntry `json:"labels"`
	Owner                *Person                `json:"owner"`
	Status               string                 `json:"status"`
	Submittable          bool                   `json:"submittable"`
	Topic                string                 `json:"topic"`
	WorkInProgress       bool                   `json:"work_in_progress"`
	CherrypickOfChange   int                    `json:"cherry_pick_of_change"`
	CherrypickOfPatchSet int                    `json:"cherry_pick_of_patch_set"`
}

ChangeInfo contains information about a Gerrit issue.

func CreateAndEditChange

func CreateAndEditChange(ctx context.Context, g GerritInterface, project, branch, commitMsg, baseCommit, baseChangeID string, fn func(context.Context, GerritInterface, *ChangeInfo) error) (*ChangeInfo, error)

CreateAndEditChange is a helper which creates a new Change in the given project based on the given branch with the given commit message. Pass in a function which modifies a ChangeEdit, and the result will be automatically published as a new patch set, or in the case of failure, reverted. If an error is encountered after the Change is created, the ChangeInfo is returned so that the caller can decide whether to abandon the change or try again.

func CreateCLFromLocalDiffs

func CreateCLFromLocalDiffs(ctx context.Context, g GerritInterface, project, branch, commitMsg string, reviewers []string, co git.Checkout) (*ChangeInfo, error)

CreateCLFromLocalDiffs is a helper which creates a Change based on the diffs from the provided branch in a local checkout. Note that the diff is performed against the given branch on "origin", and not any local version.

func CreateCLWithChanges

func CreateCLWithChanges(ctx context.Context, g GerritInterface, project, branch, commitMsg, baseCommit, baseChangeID string, changes map[string]string, reviewers []string) (*ChangeInfo, error)

CreateCLWithChanges is a helper which creates a new Change in the given project based on the given branch with the given commit message and the given map of filepath to new file contents. Empty file contents indicate deletion of the file. If reviewers are provided, the change is sent for review.

func (*ChangeInfo) GetAbandonReason

func (ci *ChangeInfo) GetAbandonReason(ctx context.Context) string

GetAbandonReason returns the reason entered by the user that abandoned the change.

func (*ChangeInfo) GetNonTrivialPatchSets

func (ci *ChangeInfo) GetNonTrivialPatchSets() []*Revision

GetNonTrivialPatchSets finds the set of non-trivial patchsets. Returns the Revisions in order of patchset number. Note that this is only correct for Chromium Gerrit instances because it makes Chromium-specific assumptions.

func (*ChangeInfo) GetPatchsetIDs

func (ci *ChangeInfo) GetPatchsetIDs() []int64

GetPatchsetIDs is a convenience function that returns the sorted list of patchset IDs.

func (*ChangeInfo) IsClosed

func (ci *ChangeInfo) IsClosed() bool

IsClosed returns true iff the issue corresponding to the ChangeInfo is abandoned or merged.

func (*ChangeInfo) IsMerged

func (ci *ChangeInfo) IsMerged() bool

IsMerged returns true iff the issue corresponding to the ChangeInfo is merged.

type ChangeInfoMessage

type ChangeInfoMessage struct {
	Tag     string `json:"tag"`
	Message string `json:"message"`
}

ChangeInfoMessage contains information about Gerrit messages.

type CodeReviewCache

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

CodeReviewCache is an LRU cache for Gerrit Issues that polls in the background to determine if issues have been updated. If so it expels them from the cache to force a reload.

func NewCodeReviewCache

func NewCodeReviewCache(gerritAPI *Gerrit, pollInterval time.Duration, cacheSize int) *CodeReviewCache

NewCodeReviewCache returns a new cache for the given API instance, poll interval and maximum cache size.

func (*CodeReviewCache) Add

func (c *CodeReviewCache) Add(key int64, value *ChangeInfo)

Add an issue to the cache.

func (*CodeReviewCache) Get

func (c *CodeReviewCache) Get(key int64) (*ChangeInfo, bool)

Get retrieves an issue from the cache.

type CommitInfo

type CommitInfo struct {
	Commit  string        `json:"commit"`
	Parents []*CommitInfo `json:"parents"`
	Subject string        `json:"subject"`
	Message string        `json:"message"`
	Author  *Person       `json:"author"`
}

CommitInfo captures information about the commit of a revision (patchset) See https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#commit-info

type Config

type Config struct {
	// Labels to set to self-approve a change. For some projects this is the
	// same as a normal approval.
	SelfApproveLabels map[string]int

	// Whether or not this project has a Commit Queue.
	HasCq bool

	// Labels to set to run the Commit Queue.
	SetCqLabels map[string]int
	// Labels to set to run the Commit Queue in dry run mode.
	SetDryRunLabels map[string]int
	// Labels to set to remove from the Commit Queue.
	NoCqLabels map[string]int

	// If the issue is open and all of these labels are set, the Commit
	// Queue is considered active.
	CqActiveLabels map[string]int
	// If the issue is merged or all of these labels are set, the Commit
	// Queue is considered to have finished successfully.
	CqSuccessLabels map[string]int
	// If the issue is abandoned or all of these labels are set, the Commit
	// Queue is considered to have failed.
	CqFailureLabels map[string]int
	// CqLabelsUnsetOnCompletion is true if the commit queue unsets the
	// labels when it finishes.
	CqLabelsUnsetOnCompletion bool

	// If the issue is open and all of these labels are set, the dry run is
	// considered active.
	DryRunActiveLabels map[string]int
	// If the issue is merged or all of these labels are set, the dry run is
	// considered to have finished successfuly.
	DryRunSuccessLabels map[string]int
	// If the issue is abandoned or all of these labels are set, the dry run
	// is considered to have failed.
	DryRunFailureLabels map[string]int
	// DryRunUsesTryjobResults is true if tryjob results should be factored
	// into dry run success.
	DryRunUsesTryjobResults bool
}

Config describes the configuration for a Gerrit host. TODO(borenet): Consider making Config into an interface with function calls for the various sets of labels and logic below. This format nicely groups the logic into one place but makes it difficult to understand and change.

func (*Config) CqRunning

func (c *Config) CqRunning(ci *ChangeInfo) bool

CqRunning returns true if the commit queue is still running. Returns false if the change is merged or abandoned.

func (*Config) CqSuccess

func (c *Config) CqSuccess(ci *ChangeInfo) bool

CqSuccess returns true if the commit queue has finished successfully. This requires that the change is merged; CqSuccess returns false if the change is not merged, even if the commit queue finishes (ie. the relevant label is removed) and all trybots were successful or a CqSuccessLabel is applied.

func (*Config) DryRunRunning

func (c *Config) DryRunRunning(ci *ChangeInfo) bool

DryRunRunning returns true if the dry run is still running. Returns false if the change is merged or abandoned.

func (*Config) DryRunSuccess

func (c *Config) DryRunSuccess(ci *ChangeInfo, allTrybotsSucceeded bool) bool

DryRunSuccess returns true if the dry run succeeded. The allTrybotsSucceeded parameter indicates whether or not all of the relevant trybots for this change succeeded; it is unused if Config.DryRunUsesTryjobResults is false.

type FileInfo

type FileInfo struct {
	Status        FileInfoStatus `json:"status"`
	Binary        bool           `json:"binary"`
	OldPath       string         `json:"old_path"`
	LinesInserted int            `json:"lines_inserted"`
	LinesDeleted  int            `json:"lines_deleted"`
	SizeDelta     int            `json:"size_delta"`
	Size          int            `json:"size"`
}

FileInfo provides information about changes to a File in Gerrit.

type FileInfoStatus

type FileInfoStatus string

FileInfoStatus is the type of 'Status' in FileInfo. https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#file-info

const (
	FileAdded     FileInfoStatus = "A"
	FileCopied    FileInfoStatus = "C"
	FileDeleted   FileInfoStatus = "D"
	FileModified  FileInfoStatus = ""
	FileRenamed   FileInfoStatus = "R"
	FileRewritten FileInfoStatus = "W"
)

type Gerrit

type Gerrit struct {
	BuildbucketClient *buildbucket.Client
	// contains filtered or unexported fields
}

Gerrit is an object used for interacting with the issue tracker.

func NewGerrit

func NewGerrit(gerritUrl string, client *http.Client) (*Gerrit, error)

NewGerrit returns a new Gerrit instance.

func NewGerritWithConfig

func NewGerritWithConfig(cfg *Config, gerritUrl string, client *http.Client) (*Gerrit, error)

NewGerritWithConfig returns a new Gerrit instance which uses the given Config.

func NewGerritWithConfigAndRateLimits

func NewGerritWithConfigAndRateLimits(cfg *Config, gerritUrl string, client *http.Client, maxQPS float64, maxBurst int) (*Gerrit, error)

NewGerritWithConfigAndRateLimits returns a new Gerrit instance which uses the given Config and rate limit options.

func (*Gerrit) Abandon

func (g *Gerrit) Abandon(ctx context.Context, issue *ChangeInfo, message string) error

Abandon abandons the issue with the given message.

func (*Gerrit) AddCC

func (g *Gerrit) AddCC(ctx context.Context, issue *ChangeInfo, ccList []string) error

AddCC adds CCs to the issues.

func (*Gerrit) AddComment

func (g *Gerrit) AddComment(ctx context.Context, issue *ChangeInfo, message string) error

AddComment adds a message to the issue.

func (*Gerrit) Approve

func (g *Gerrit) Approve(ctx context.Context, issue *ChangeInfo, message string) error

Approve sets the Code Review label to indicate approval.

func (*Gerrit) Config

func (g *Gerrit) Config() *Config

Config returns the Config object used by this Gerrit.

func (*Gerrit) CreateChange

func (g *Gerrit) CreateChange(ctx context.Context, project, branch, subject, baseCommit, baseChangeID string) (*ChangeInfo, error)

CreateChange creates a new Change in the given project, based on a given Git commit or Gerrit change ID, on on the given branch, and with the given subject line.

func (*Gerrit) CreateCherryPickChange

func (g *Gerrit) CreateCherryPickChange(ctx context.Context, changeID, revisionID, msg, destBranch string) (*ChangeInfo, error)

CreateCherryPickChange will cherry-pick a revision into a destination branch.

https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#cherry-pick

  • changeID: Identifier that uniquely identifies one change. It contains the URL-encoded project name as well as the change number: "'<project>~<changeNumber>'"
  • revisionID: Identifier that uniquely identifies one revision of a change.
  • msg: Text to be added as a commit message.
  • destBranch: The cherry-pick destination branch.

func (*Gerrit) DeleteChangeEdit

func (g *Gerrit) DeleteChangeEdit(ctx context.Context, ci *ChangeInfo) error

DeleteChangeEdit deletes the active ChangeEdit, restoring the state to the last patch set.

func (*Gerrit) DeleteFile

func (g *Gerrit) DeleteFile(ctx context.Context, ci *ChangeInfo, filepath string) error

DeleteFile deletes the given file. A ChangeEdit is created, if one is not already active. You must call PublishChangeEdit in order for the change to become a new patch set, otherwise it has no effect.

func (*Gerrit) DeleteVote

func (g *Gerrit) DeleteVote(ctx context.Context, changeNum int64, labelID string, accountID int, notify NotifyOption, ignoreAutomaticAttentionSetRules bool) error

DeleteVote deletes a single vote from a change. Documentation is here: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#delete-vote

func (*Gerrit) Disapprove

func (g *Gerrit) Disapprove(ctx context.Context, issue *ChangeInfo, message string) error

Disapprove sets the Code Review label to indicate disapproval.

func (*Gerrit) DownloadCommitMsgHook

func (g *Gerrit) DownloadCommitMsgHook(ctx context.Context, dest string) error

DownloadCommitMsgHook downloads the commit message hook to the specified location.

func (*Gerrit) EditFile

func (g *Gerrit) EditFile(ctx context.Context, ci *ChangeInfo, filepath, content string) error

EditFile modifies the given file to have the given content. A ChangeEdit is created, if one is not already active. You must call PublishChangeEdit in order for the change to become a new patch set, otherwise it has no effect.

func (*Gerrit) ExtractIssueFromCommit

func (g *Gerrit) ExtractIssueFromCommit(commitMsg string) (int64, error)

ExtractIssueFromCommit returns the issue id by parsing the commit message of a landed commit. It expects the commit message to contain one line in this format:

Reviewed-on: https://skia-review.googlesource.com/999999

where the digits at the end are the issue id.

func (*Gerrit) Files

func (g *Gerrit) Files(ctx context.Context, issue int64, patch string) (map[string]*FileInfo, error)

Files returns the files that were modified, added or deleted in a revision. https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#list-files

func (*Gerrit) GetChange

func (g *Gerrit) GetChange(ctx context.Context, id string) (*ChangeInfo, error)

GetChange returns the ChangeInfo object for the given ID.

func (*Gerrit) GetCommit

func (g *Gerrit) GetCommit(ctx context.Context, issue int64, revision string) (*CommitInfo, error)

GetCommit retrieves the commit that corresponds to the patch identified by issue and revision. It allows to retrieve the parent commit on which the given patchset is based on. See: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-commit

func (*Gerrit) GetContent

func (g *Gerrit) GetContent(ctx context.Context, issue int64, revision string, filePath string) (string, error)

GetContent gets the content of a file from the specified revision. See: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-content

func (*Gerrit) GetDependencies

func (g *Gerrit) GetDependencies(ctx context.Context, changeNum int64, revision int) ([]*RelatedChangeAndCommitInfo, error)

GetDependencies returns a slice of all dependencies around the specified change. See https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-related-changes

func (*Gerrit) GetFileNames

func (g *Gerrit) GetFileNames(ctx context.Context, issue int64, patch string) ([]string, error)

GetFileNames returns the list of files for the given issue at the given patch. If patch is the empty string then the most recent patch is queried.

func (*Gerrit) GetFilesToContent

func (g *Gerrit) GetFilesToContent(ctx context.Context, issue int64, revision string) (map[string]string, error)

GetFilesToContent returns a map of files in the specified issue+revision to their content.

func (*Gerrit) GetIssueProperties

func (g *Gerrit) GetIssueProperties(ctx context.Context, issue int64) (*ChangeInfo, error)

GetIssueProperties returns a fully filled-in ChangeInfo object, as opposed to the partial data returned by Gerrit's search endpoint. If the given issue cannot be found ErrNotFound is returned as error.

func (*Gerrit) GetPatch

func (g *Gerrit) GetPatch(ctx context.Context, issue int64, revision, path string) (string, error)

GetPatch returns the formatted patch for one revision. Documentation is here: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-patch

func (*Gerrit) GetRepoUrl

func (g *Gerrit) GetRepoUrl() string

GetRepoUrl returns the url of the Googlesource repo.

func (*Gerrit) GetTrybotResults

func (g *Gerrit) GetTrybotResults(ctx context.Context, issueID int64, patchsetID int64) ([]*buildbucketpb.Build, error)

GetTrybotResults retrieves the trybot results for the given change from BuildBucket.

func (*Gerrit) GetUserEmail

func (g *Gerrit) GetUserEmail(ctx context.Context) (string, error)

GetUserEmail returns the Gerrit user's email address.

func (*Gerrit) HasOpenDependency

func (g *Gerrit) HasOpenDependency(ctx context.Context, changeNum int64, revision int) (bool, error)

HasOpenDependency returns true if there is an active direct dependency of the specified change.

func (*Gerrit) Initialized

func (g *Gerrit) Initialized() bool

Initialized returns false if the implementation of GerritInterface has not been initialized (i.e. it is a pointer to nil).

func (*Gerrit) IsBinaryPatch

func (g *Gerrit) IsBinaryPatch(ctx context.Context, issue int64, revision string) (bool, error)

IsBinaryPatch returns true if the patch contains any binary files.

func (*Gerrit) MoveFile

func (g *Gerrit) MoveFile(ctx context.Context, ci *ChangeInfo, oldPath, newPath string) error

MoveFile moves a given file. A ChangeEdit is created, if one is not already active. You must call PublishChangeEdit in order for the change to become a new patch set, otherwise it has no effect.

func (*Gerrit) NoScore

func (g *Gerrit) NoScore(ctx context.Context, issue *ChangeInfo, message string) error

NoScore unsets the Code Review label.

func (*Gerrit) PublishChangeEdit

func (g *Gerrit) PublishChangeEdit(ctx context.Context, ci *ChangeInfo) error

PublishChangeEdit publishes the active ChangeEdit as a new patch set.

func (*Gerrit) Rebase

func (g *Gerrit) Rebase(ctx context.Context, ci *ChangeInfo, base string, allowConflicts bool) error

Rebase the given change onto the given optional base. If not provided, the change is rebased onto the target branch. If allowConflicts is true, the rebase succeeds even if there are conflicts, in which case the patch set will contain git conflict markers.

func (*Gerrit) RemoveFromCQ

func (g *Gerrit) RemoveFromCQ(ctx context.Context, issue *ChangeInfo, message string) error

RemoveFromCQ unsets the Commit Queue labels on the Change.

func (*Gerrit) Search

func (g *Gerrit) Search(ctx context.Context, limit int, sortResults bool, terms ...*SearchTerm) ([]*ChangeInfo, error)

Search returns a slice of Issues which fit the given criteria.

func (*Gerrit) SelfApprove

func (g *Gerrit) SelfApprove(ctx context.Context, issue *ChangeInfo, message string) error

SelfApprove sets the Code Review label to indicate self-approval.

func (*Gerrit) SendToCQ

func (g *Gerrit) SendToCQ(ctx context.Context, issue *ChangeInfo, message string) error

SendToCQ sets the Commit Queue labels on the Change.

func (*Gerrit) SendToDryRun

func (g *Gerrit) SendToDryRun(ctx context.Context, issue *ChangeInfo, message string) error

SendToDryRun sets the Commit Queue dry run labels on the Change.

func (*Gerrit) SetCommitMessage

func (g *Gerrit) SetCommitMessage(ctx context.Context, ci *ChangeInfo, msg string) error

SetCommitMessage sets the commit message for the ChangeEdit. A ChangeEdit is created, if one is not already active. You must call PublishChangeEdit in order for the change to become a new patch set, otherwise it has no effect.

func (*Gerrit) SetReadyForReview

func (g *Gerrit) SetReadyForReview(ctx context.Context, ci *ChangeInfo) error

SetReadyForReview marks the change as ready for review (ie, not WIP).

func (*Gerrit) SetReview

func (g *Gerrit) SetReview(ctx context.Context, issue *ChangeInfo, message string, labels map[string]int, reviewers []string, notify NotifyOption, notifyDetails NotifyDetails, tag string, onBehalfOf int, attentionSetInputs []*AttentionSetInput) error

SetReview calls the Set Review endpoint of the Gerrit API to add messages and/or set labels for the latest patchset. API documentation: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#set-review notifyDetails contains additional information about whom to notify about the update. See details in https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#review-input onBehalfOf is expected to be the accountId the review should be posted on behalf of. Set to 0 to not use this functionality. attentionSetInputs contains details for adding users to the attension set. See details in https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#attention-set-input

func (*Gerrit) SetTopic

func (g *Gerrit) SetTopic(ctx context.Context, topic string, changeNum int64) error

SetTopic sets a topic on the Gerrit change with the provided id.

func (*Gerrit) SetTraceIDPrefix

func (g *Gerrit) SetTraceIDPrefix(traceIdPrefix string)

SetTraceIDPrefix enables tracing for all requests, with the given prefix. The full trace ID consists of the prefix and the timestamp of the request. If an empty string is provided, tracing is disabled. It is recommended to use an issue number for the trace ID, eg. "issue/123"

func (*Gerrit) Submit

func (g *Gerrit) Submit(ctx context.Context, ci *ChangeInfo) error

Submit submits the Change.

func (*Gerrit) SubmittedTogether

func (g *Gerrit) SubmittedTogether(ctx context.Context, ci *ChangeInfo) ([]*ChangeInfo, int, error)

SubmittedTogether returns list of all changes which are submitted when Submit is called for this change, including the current change itself. If the user calling the API does not have access to some changes then non_visible_changes will be > 0.

func (*Gerrit) Url

func (g *Gerrit) Url(issueID int64) string

Url returns the url of the Gerrit issue identified by issueID or the base URL of the Gerrit instance if issueID is 0.

type GerritInterface

type GerritInterface interface {
	Abandon(context.Context, *ChangeInfo, string) error
	AddComment(context.Context, *ChangeInfo, string) error
	AddCC(context.Context, *ChangeInfo, []string) error
	Approve(context.Context, *ChangeInfo, string) error
	Config() *Config
	CreateChange(context.Context, string, string, string, string, string) (*ChangeInfo, error)
	CreateCherryPickChange(context.Context, string, string, string, string) (*ChangeInfo, error)
	DeleteChangeEdit(context.Context, *ChangeInfo) error
	DeleteFile(context.Context, *ChangeInfo, string) error
	DeleteVote(context.Context, int64, string, int, NotifyOption, bool) error
	Disapprove(context.Context, *ChangeInfo, string) error
	DownloadCommitMsgHook(ctx context.Context, dest string) error
	EditFile(context.Context, *ChangeInfo, string, string) error
	ExtractIssueFromCommit(string) (int64, error)
	Files(ctx context.Context, issue int64, patch string) (map[string]*FileInfo, error)
	GetChange(ctx context.Context, id string) (*ChangeInfo, error)
	GetCommit(ctx context.Context, issue int64, revision string) (*CommitInfo, error)
	GetContent(context.Context, int64, string, string) (string, error)
	GetFileNames(ctx context.Context, issue int64, patch string) ([]string, error)
	GetFilesToContent(ctx context.Context, issue int64, revision string) (map[string]string, error)
	GetIssueProperties(context.Context, int64) (*ChangeInfo, error)
	GetPatch(context.Context, int64, string, string) (string, error)
	GetRepoUrl() string
	GetTrybotResults(context.Context, int64, int64) ([]*buildbucketpb.Build, error)
	GetUserEmail(context.Context) (string, error)
	Initialized() bool
	IsBinaryPatch(ctx context.Context, issue int64, patch string) (bool, error)
	MoveFile(context.Context, *ChangeInfo, string, string) error
	NoScore(context.Context, *ChangeInfo, string) error
	PublishChangeEdit(context.Context, *ChangeInfo) error
	Rebase(context.Context, *ChangeInfo, string, bool) error
	RemoveFromCQ(context.Context, *ChangeInfo, string) error
	Search(context.Context, int, bool, ...*SearchTerm) ([]*ChangeInfo, error)
	SelfApprove(context.Context, *ChangeInfo, string) error
	SendToCQ(context.Context, *ChangeInfo, string) error
	SendToDryRun(context.Context, *ChangeInfo, string) error
	SetCommitMessage(context.Context, *ChangeInfo, string) error
	SetReadyForReview(context.Context, *ChangeInfo) error
	SetReview(context.Context, *ChangeInfo, string, map[string]int, []string, NotifyOption, NotifyDetails, string, int, []*AttentionSetInput) error
	SetTopic(context.Context, string, int64) error
	SetTraceIDPrefix(traceIdPrefix string)
	Submit(context.Context, *ChangeInfo) error
	SubmittedTogether(context.Context, *ChangeInfo) ([]*ChangeInfo, int, error)
	Url(int64) string
}

GerritInterface describes interactions with a Gerrit host.

type LabelDetail

type LabelDetail struct {
	Name      string `json:"name"`
	Email     string `json:"email"`
	Date      string `json:"date"`
	Value     int    `json:"value"`
	AccountID int    `json:"_account_id"`
}

LabelDetail provides details about a label set on a Change in Gerrit.

type LabelEntry

type LabelEntry struct {
	All          []*LabelDetail
	Values       map[string]string
	DefaultValue int
}

LabelEntry describes a label set on a Change in Gerrit.

type NotifyDetails

type NotifyDetails map[RecipientType]*NotifyInfo

type NotifyInfo

type NotifyInfo struct {
	Accounts []string `json:"accounts"`
}

type NotifyOption

type NotifyOption string

The different notify options supported by Gerrit. See the notify property in https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#review-input

const NotifyAll NotifyOption = "ALL"
const NotifyDefault NotifyOption = ""
const NotifyNone NotifyOption = "NONE"
const NotifyOwner NotifyOption = "OWNER"
const NotifyOwnerReviewers NotifyOption = "OWNER_REVIEWERS"

type Person

type Person struct {
	AccountID int    `json:"_account_id"`
	Email     string `json:"email"`
	Name      string `json:"name"`
}

Person describes a person in Gerrit.

type RecipientType

type RecipientType string

The different recipient types supported by Gerrit. https://gerrit-review.googlesource.com/Documentation/user-notify.html#recipient-types

type RelatedChangeAndCommitInfo

type RelatedChangeAndCommitInfo struct {
	ChangeId string `json:"change_id"`
	Issue    int64  `json:"_change_number"`
	Revision int64  `json:"_revision_number"`
	Status   string `json:"status"`
}

RelatedChangeAndCommitInfo entity contains information about a related change and commit.

type RelatedChangesInfo

type RelatedChangesInfo struct {
	Changes []*RelatedChangeAndCommitInfo `json:"changes"`
}

The RelatedChangesInfo entity contains information about related changes.

type Reviewer

type Reviewer struct {
	Reviewer string `json:"reviewer"`
}

type Revision

type Revision struct {
	ID            string    `json:"-"`
	Number        int64     `json:"_number"`
	CreatedString string    `json:"created"`
	Created       time.Time `json:"-"`
	Kind          string    `json:"kind"`
	Ref           string    `json:"ref"`
}

Revision is the information associated with a patchset in Gerrit.

type SearchTerm

type SearchTerm struct {
	Key   string
	Value string
}

SearchTerm is a wrapper for search terms to pass into the Search method.

func SearchBranch

func SearchBranch(branch string) *SearchTerm

SearchBranch is a SearchTerm used for filtering by branch.

func SearchCherrypickOf

func SearchCherrypickOf(changeNum int) *SearchTerm

SearchCherrypickOf is a SearchTerm used for finding all cherrypicks of the specified change.

func SearchCommit

func SearchCommit(commit string) *SearchTerm

SearchCommit is a SearchTerm used for filtering by commit.

func SearchLabel

func SearchLabel(label, value string) *SearchTerm

SearchLabel is a SearchTerm used for filtering by label.

func SearchModifiedAfter

func SearchModifiedAfter(after time.Time) *SearchTerm

SearchModifiedAfter is a SearchTerm used for finding issues modified after a particular time.Time. API documentation is here: https://review.openstack.org/Documentation/user-search.html

func SearchOwner

func SearchOwner(name string) *SearchTerm

SearchOwner is a SearchTerm used for filtering by issue owner. API documentation is here: https://review.openstack.org/Documentation/user-search.html

func SearchProject

func SearchProject(project string) *SearchTerm

SearchProject is a SearchTerm used for filtering by project.

func SearchStatus

func SearchStatus(status string) *SearchTerm

SearchStatus is a SearchTerm used for filtering by status.

func SearchTopic

func SearchTopic(topic string) *SearchTerm

SearchTopic is a SearchTerm used for filtering by topic.

type SubmittedTogetherInfo

type SubmittedTogetherInfo struct {
	Changes           []*ChangeInfo `json:"changes"`
	NonVisibleChanges int           `json:"non_visible_changes"`
}

The SubmittedTogetherInfo entity contains information about submitted together changes.

Directories

Path Synopsis
Package rubberstamper contains some utilities for having the RubberStamper bot automatically submit a CL.
Package rubberstamper contains some utilities for having the RubberStamper bot automatically submit a CL.

Jump to

Keyboard shortcuts

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