Documentation
¶
Overview ¶
Package gerrit contains Gerrit utility functions.
Index ¶
- Constants
- func EquivalentPatchsetRange(info *gerritpb.ChangeInfo) (minEquiPatchset, currentPatchset int, err error)
- func SaveLegacyNetrcToken(ctx context.Context, host, token string) error
- func TruncateMessage(msg string) string
- func UnhandledError(ctx context.Context, err error, format string, args ...interface{}) error
- type Client
- type ClientFactory
Constants ¶
const MaxMessageLength = 16384
MaxMessageLength is the max message length for Gerrit as of Jun 2020 based on error messages.
const PlaceHolder = "\n...[truncated too long message]"
PlaceHolder is added to the message when the length of the message exceeds `MaxMessageLength` and human message gets truncated.
Variables ¶
This section is empty.
Functions ¶
func EquivalentPatchsetRange ¶
func EquivalentPatchsetRange(info *gerritpb.ChangeInfo) (minEquiPatchset, currentPatchset int, err error)
EquivalentPatchsetRange computes range of patchsets code-wise equivalent to the current patchset.
Gerrit categorises each new patchset (aka Revision) according to difference from prior one. The rebases are counted as equivalent, even though dependencies may have changed. Thus, only REWORK changes code.
Generally, all patchsets are numbered 1,2,3,...n without gaps. But this function doesn't assume this, thus Gerrit might potentially support wiping out individual patchsets, creating gaps without affecting CV.
func SaveLegacyNetrcToken ¶
SaveLegacyNetrcToken creates or updates legacy netrc token.
func TruncateMessage ¶
TruncateMessage truncates the message and appends `PlaceHolder` so that the string doesn't exceed `MaxMessageLength`.
If the input message is a valid utf-8 string, the result string will also be a valid utf-8 string
Types ¶
type Client ¶
type Client interface { // Lists changes that match a query. // // Note, although the Gerrit API supports multiple queries, for which // it can return multiple lists of changes, this is not a foreseen use-case // so this API just includes one query with one returned list of changes. // // https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#list-changes ListChanges(ctx context.Context, in *gerritpb.ListChangesRequest, opts ...grpc.CallOption) (*gerritpb.ListChangesResponse, error) // Loads a change by id. // // https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-change GetChange(ctx context.Context, in *gerritpb.GetChangeRequest, opts ...grpc.CallOption) (*gerritpb.ChangeInfo, error) // Retrieves related changes of a revision. // // Related changes are changes that either depend on, or are dependencies of // the revision. // // https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-related-changes GetRelatedChanges(ctx context.Context, in *gerritpb.GetRelatedChangesRequest, opts ...grpc.CallOption) (*gerritpb.GetRelatedChangesResponse, error) // Lists the files that were modified, added or deleted in a revision. // // https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#list-files ListFiles(ctx context.Context, in *gerritpb.ListFilesRequest, opts ...grpc.CallOption) (*gerritpb.ListFilesResponse, error) // Set various review bits on a change. // // https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#set-review SetReview(ctx context.Context, in *gerritpb.SetReviewRequest, opts ...grpc.CallOption) (*gerritpb.ReviewResult, error) // Submit a specific revision of a change. // // https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#submit-revision SubmitRevision(ctx context.Context, in *gerritpb.SubmitRevisionRequest, opts ...grpc.CallOption) (*gerritpb.SubmitInfo, error) }
Client defines a subset of Gerrit API used by CV.
type ClientFactory ¶
ClientFactory creates Client tied to Gerrit host and LUCI project.
Gerrit host and LUCI project determine the authentication being used.
func CachingFactory ¶
func CachingFactory(lruSize int, f ClientFactory) ClientFactory
CachingFactory caches clients produced by another ClientFactory.
func InstrumentedFactory ¶
func InstrumentedFactory(f ClientFactory) ClientFactory
InstrumentedFactory instruments RPCs.
func NewFactory ¶
func NewFactory(ctx context.Context) (ClientFactory, error)
NewFactory returns ClientFactory for use in production.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package botdata implements parsing and generation logic for BotData.
|
Package botdata implements parsing and generation logic for BotData. |
Package cancel implements cancelling triggers of Run by removing CQ Votes on a CL.
|
Package cancel implements cancelling triggers of Run by removing CQ Votes on a CL. |
Package cfgmatcher efficiently matches a CL to 0+ ConfigGroupID for a single LUCI project.
|
Package cfgmatcher efficiently matches a CL to 0+ ConfigGroupID for a single LUCI project. |
Package cqdepend parses CQ-Depend directives in CL description.
|
Package cqdepend parses CQ-Depend directives in CL description. |
Package gerritfake implements fake Gerrit for needs of CV tests.
|
Package gerritfake implements fake Gerrit for needs of CV tests. |
Package gobmap finds relevant LUCI project config given a Gerrit CL.
|
Package gobmap finds relevant LUCI project config given a Gerrit CL. |
gobmaptest
Package gobmaptest eases use of gobmap package in tests.
|
Package gobmaptest eases use of gobmap package in tests. |
Package poller polls Gerrit for interesting CV changes.
|
Package poller polls Gerrit for interesting CV changes. |
Package trigger determines if and how Gerrit CL is triggered.
|
Package trigger determines if and how Gerrit CL is triggered. |
Package updater fetches latest CL data from Gerrit.
|
Package updater fetches latest CL data from Gerrit. |
updatertest
Package updatertest provides test helpers for Gerrit CL Updater.
|
Package updatertest provides test helpers for Gerrit CL Updater. |