Documentation
¶
Overview ¶
Package gerrit mirrors Gerrit CL state in a storage.DB.
Index ¶
- Constants
- type AccountInfo
- type ApprovalInfo
- type AttentionSetInfo
- type AvatarInfo
- type Change
- type ChangeEvent
- type ChangeInfo
- type ChangeMessageInfo
- type ChangeTimes
- type Client
- func (c *Client) Add(project string) error
- func (c *Client) Change(project string, changeNum int) *Change
- func (c *Client) ChangeCommentCounts(ch *Change) (total, unresolved int)
- func (c *Client) ChangeCommitAuthor(ch *Change, patchset int) *GitPersonInfo
- func (c *Client) ChangeDescription(ch *Change) string
- func (c *Client) ChangeHashtags(ch *Change) []string
- func (c *Client) ChangeInfo(ch *Change) *ChangeInfo
- func (c *Client) ChangeLabel(ch *Change, label string) *LabelInfo
- func (c *Client) ChangeLabels(ch *Change) map[string]*LabelInfo
- func (c *Client) ChangeMessages(ch *Change) []*ChangeMessageInfo
- func (c *Client) ChangeNumber(ch *Change) int
- func (c *Client) ChangeNumbers(project string) iter.Seq2[int, func() *Change]
- func (c *Client) ChangeOwner(ch *Change) *AccountInfo
- func (c *Client) ChangeProject(ch *Change) string
- func (c *Client) ChangeReviewers(ch *Change) []*AccountInfo
- func (c *Client) ChangeRevisions(ch *Change) []*RevisionInfo
- func (c *Client) ChangeStatus(ch *Change) string
- func (c *Client) ChangeSubject(ch *Change) string
- func (c *Client) ChangeSubmitter(ch *Change) *AccountInfo
- func (c *Client) ChangeTimes(ch *Change) ChangeTimes
- func (c *Client) ChangeWatcher(name string) *timed.Watcher[*ChangeEvent]
- func (c *Client) ChangeWorkInProgress(ch *Change) bool
- func (c *Client) Comments(project string, changeNum int) map[string][]*CommentInfo
- func (c *Client) DocWatcher() *timed.Watcher[*ChangeEvent]
- func (c *Client) RequestFlush()
- func (c *Client) Sync(ctx context.Context) error
- func (c *Client) SyncProject(ctx context.Context, project string) (err error)
- func (c *Client) Testing() *TestingClient
- func (c *Client) ToDocs(ce *ChangeEvent) (iter.Seq[*docs.Doc], bool)
- type CommentInfo
- type CommentRange
- type CommitInfo
- type FixReplacementInfo
- type FixSuggestionInfo
- type GitPersonInfo
- type LabelInfo
- type ParentInfo
- type Requirement
- type RevisionInfo
- type SubmitRecordInfo
- type TestingClient
- type TimeStamp
- type VotingRangeInfo
- type WebLinkInfo
Constants ¶
const DocWatcherID = "gerritrelateddocs"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountInfo ¶
type AccountInfo struct { // The numeric ID of the account. AccountID int `json:"_account_id"` // The full name of the user. Name string `json:"name,omitempty"` // The display name of the user. DisplayName string `json:"display_name,omitempty"` // The email address the user prefers to be contacted through. Email string `json:"email,omitempty"` // The username of the user. UserName string `json:"username,omitempty"` // List of [AvatarInfo] entities that provide information about // avatar images of the account. Avatars []*AvatarInfo `json:"avatars,omitempty"` // Status message of the account. Status string `json:"status,omitempty"` // Whether the account is inactive. Inactive bool `json:"inactive,omitempty"` // List of additional tags that this account has. The only // current tag an account can have is SERVICE_USER. Tags []string `json:"tags,omitempty"` }
AccountInfo contains information about an account. This describes Gerrit JSON data.
type ApprovalInfo ¶
type ApprovalInfo struct { // The account that approved. *AccountInfo // The vote that the user has given for the label. If present // and zero, the user is permitted to vote on the label. If // absent, the user is not permitted to vote on that label. Value int `json:"value,omitempty"` // The VotingRangeInfo the user is authorized to vote on that // label. If present, the user is permitted to vote on the // label regarding the range values. If absent, the user is // not permitted to vote on that label. PermittedVotingRange VotingRangeInfo `json:"permitted_voting_range,omitempty"` // The time and date describing when the approval was made. Date TimeStamp `json:"date,omitempty"` // Value of the tag field from ReviewInput set while posting // the review. Votes/comments that contain tag with // 'autogenerated:' prefix can be filtered out in the web UI. Tag string `json:"tag,omitempty"` // If true, this vote was made after the change was submitted. PostSubmit bool `json:"post_submit,omitempty"` }
ApprovalInfo holds information about an approval from a user for a label on a change. This describes Gerrit JSON data.
type AttentionSetInfo ¶
type AttentionSetInfo struct { // The account. Account *AccountInfo `json:"account"` // The timestamp of the last update. LastUpdate TimeStamp `json:"last_update"` // The reason for adding or removing the user. If the update // was caused by another user, that account is represented by // account ID in reason as <GERRIT_ACCOUNT_18419> and the // corresponding AccountInfo can be found in reason_account field. Reason string `json:"reason"` // AccountInfo of the user who caused the update. ReasonAccount *AccountInfo `json:"reason_account"` }
AttentionSetInfo describes users in the Gerrit attention set. This describes Gerrit JSON data.
type AvatarInfo ¶
type AvatarInfo struct { // The URL to the avatar image. URL string `json:"url"` // The height of the avatar image in pixels. Height int `json:"height"` // The width of the avatar image in pixels. Width int `json:"width,omitempty"` }
AvatarInfo holds Information about an avatar image of an account. This describes Gerrit JSON data.
type Change ¶
type Change struct {
// contains filtered or unexported fields
}
A Change holds information for a single Gerrit change. This internally holds JSON encoded data, and only decodes what is needed.
type ChangeEvent ¶
type ChangeEvent struct { DBTime timed.DBTime // when event was created Instance string // Gerrit instance ChangeNum int // change number }
A ChangeEvent is a Gerrit CL change event returned by ChangeWatcher.
func (*ChangeEvent) LastWritten ¶
func (ce *ChangeEvent) LastWritten() timed.DBTime
LastWritten implements docs.Entry.LastWritten.
type ChangeInfo ¶
type ChangeInfo struct { // ID of the change, currently <project>~<number>. ID string `json:"id,omitempty"` // Triplet ID, currently <project>~<branch>~<number>. TripletID string `json:"triplet_id,omitempty"` // The name of the project. Project string `json:"project,omitempty"` // The name of the target branch. // The refs/heads/ prefix is omitted. Branch string `json:"branch,omitempty"` // The topic to which this change belongs. Topic string `json:"topic,omitempty"` // The map that maps account IDs to AttentionSetInfo of that // account. Those are all accounts that are currently in the // attention set. AttentionSet map[int]*AttentionSetInfo `json:"attention_set,omitempty"` // The map that maps account IDs to AttentionSetInfo of that // account. Those are all accounts that were in the attention // set but were removed. The AttentionSetInfo is the latest // and most recent removal of the account from the attention set. RemovedFromAttentionSet map[int]*AttentionSetInfo `json:"removed_from_attention_set,omitempty"` Hashtags []string `json:"hashtags,omitempty"` // The Change-Id of the change. ChangeID string `json:"change_id"` // The subject of the change (header line of the commit message). Subject string `json:"subject"` // The status of the change (NEW, MERGED, ABANDONED). Status string `json:"status"` // The timestamp of when the change was created. Created TimeStamp `json:"created"` // The timestamp of when the change was last updated. Updated TimeStamp `json:"updated"` // The timestamp of when the change was submitted. Submitted TimeStamp `json:"submitted,omitempty"` // The user who submitted the change. Submitter *AccountInfo `json:"submitter,omitempty"` // The submit type of the change. Not set for merged changes. SubmitType string `json:"submit_type,omitempty"` // Whether the change has been approved by the project submit rules. Submittable bool `json:"submittable,omitempty"` // Number of inserted lines. Insertions int `json:"insertions"` // Number of deleted lines. Deletions int `json:"deletions"` // Total number of inline comments across all patch sets. TotalCommentCount int `json:"total_comment_count"` // Number of unresolved inline comment threads across all patch sets. UnresolvedCommentCount int `json:"unresolved_comment_count,omitempty"` // The change number. Number int `json:"_number"` // The virtual id number is globally unique. For local // changes, it is equal to the _number attribute. For imported // changes, the original _number is processed through a // function designed to prevent conflicts with local change // numbers. Note that its usage is intended solely for // Gerrit’s internals and UI, and adoption outside these // scenarios is not advised. VirtualIDNumber int `json:"virtual_id_number"` // The owner of the change. Owner *AccountInfo `json:"owner"` // List of the [SubmitRecordInfo] containing the submit records // for the change at the latest patchset. SubmitRecords []*SubmitRecordInfo `json:"submit_records"` // The labels of the change as a map that maps the label names // to LabelInfo entries. Labels map[string]*LabelInfo `json:"labels,omitempty"` // The reviewers as a map that maps a reviewer state to a list // of AccountInfo entities. Possible reviewer states are: // REVIEWER: Users with at least one non-zero vote on the change. // CC: Users that were added to the change, but have not voted. Reviewers map[string][]*AccountInfo `json:"reviewers,omitempty"` // Updates to reviewers that have been made while the change // was in the WIP state. Only present on WIP changes and only // if there are pending reviewer updates to report. These are // reviewers who have not yet been notified about being added // to or removed from the change. Possible states are: // REVIEWER: Users with at least one non-zero vote on the change. // CC: Users that were added to the change, but have not voted. // REMOVED: Users that were previously reviewers on the // change, but have been removed. PendingReviewers map[string][]*AccountInfo `json:"pending_reviewers,omitempty"` // Messages associated with the change. Messages []*ChangeMessageInfo `json:"messages,omitempty"` // The number of the current patch set of this change. CurrentRevisionNumber int `json:"current_revision_number"` // The commit ID of the current patch set of this change. CurrentRevision string `json:"current_revision,omitempty"` // All patch sets of this change as a map that maps the commit // ID of the patch set to a [RevisionInfo] entity. Revisions map[string]*RevisionInfo `json:"revisions,omitempty"` // The SHA-1 of the NoteDb meta ref. MetaRevID string `json:"meta_rev_id,omitempty"` // When present, change is marked as private. IsPrivate bool `json:"is_private,omitempty"` // When present, change is marked as Work In Progress. WorkInProgress bool `json:"work_in_progress,omitempty"` // When present, change has been marked Ready at some point in time. HasReviewStarted bool `json:"has_review_started,omitempty"` // The change number of the change that this change reverts. RevertOf int `json:"revert_of,omitempty"` // ID of the submission of this change. Only set if the status // is MERGED. This ID is equal to the change number of the // change that triggered the submission. If the change that // triggered the submission also has a topic, it will be // "<id>-<topic>" of the change that triggered the // submission. The callers must not rely on the format of the // submission ID. SubmissionID string `json:"submission_id,omitempty"` // The change number of the change that this change was // cherry-picked from. Only set if the cherry-pick has been // done through the Gerrit REST API (and not if a // cherry-picked commit was pushed). CherryPickOfChange int `json:"cherry_pic_of_change,omitempty"` // The patchset number of the change that this change was // cherry-picked from. Only set if the cherry-pick has been // done through the Gerrit REST API (and not if a // cherry-picked commit was pushed). CherryPickOfPatchSet int `json:"cherry_pick_of_patch_set,omitempty"` // contains filtered or unexported fields }
A ChangeInfo is the information recorded for a change. This describes Gerrit JSON data.
type ChangeMessageInfo ¶
type ChangeMessageInfo struct { // The ID of the message. ID string `json:"id"` // Author of the message as an AccountInfo entity. // Unset if written by the Gerrit system. Author *AccountInfo `json:"author,omitempty"` // Real author of the message as an AccountInfo entity. // Only set if the message was posted on behalf of another user. RealAuthor *AccountInfo `json:"real_author,omitempty"` // The timestamp this message was posted. Date TimeStamp `json:"date"` // The text left by the user or Gerrit system. Accounts are // served as account IDs inlined in the text as // <GERRIT_ACCOUNT_18419>. All accounts, used in message, can // be found in accounts_in_message field. Message string `json:"message"` // AccountInfo list, used in message. AccountsInMessage []*AccountInfo `json:"accounts_in_message,omitempty"` // Value of the tag field from ReviewInput set while posting // the review. Votes/comments that contain tag with // 'autogenerated:' prefix can be filtered out in the web UI. Tag string `json:"tag,omitempty"` // Which patchset (if any) generated this message. RevisionNumber int `json:"_revision_number,omitempty"` }
ChangeMessageInfo holds information about a message attached to a change. This describes Gerrit JSON data.
type ChangeTimes ¶
type ChangeTimes struct { Created time.Time // when change was created Updated time.Time // when change was updated, zero if never Submitted time.Time // when change was submitted, zero if not Abandoned time.Time // when change was abandoned, zero if not }
ChangeTimes holds relevant times for a Change.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is a connection to a Gerrit instance, and to the database that stores information gathered from the instance.
func New ¶
New returns a new client to access a Gerrit instance described by a host name like "go-review.googlesource.com". The client uses the given logger, databases, and HTTP client.
The secret database will look for a secret whose name is the Gerrit instance. The value will be user:pass. This is not yet used.
func (*Client) Add ¶
Add adds a Gerrit project such as "go" or "oscar" to the database. It only adds the project sync metadata. The initial data fetch does not happen until [Sync] or [SyncProject] is called. If the project is already present, Add does nothing and returns nil.
func (*Client) Change ¶
Change returns the data for a single change. This will return nil if no information is recorded.
func (*Client) ChangeCommentCounts ¶
ChangeCommentCounts returns the total number of comments and the nmber of unresolved comments.
func (*Client) ChangeCommitAuthor ¶
func (c *Client) ChangeCommitAuthor(ch *Change, patchset int) *GitPersonInfo
ChangeCommitAuthor returns the author of a given patch set number of a change. If the patch set number does not exist or the information is missing, this returns nil.
func (*Client) ChangeDescription ¶
ChangeDescription returns the current description of the change.
func (*Client) ChangeHashtags ¶
ChangeHashTags returns the list of hashtags set on the change.
func (*Client) ChangeInfo ¶
func (c *Client) ChangeInfo(ch *Change) *ChangeInfo
ChangeInfo returns a ChangeInfo holding almost all the information about a Change. This does not include the file comments, which can be retrieved using the Client.Comments method.
func (*Client) ChangeLabel ¶
ChangeLabel returns information about a label. It returns nil if that label is not present.
func (*Client) ChangeLabels ¶
ChangeLabels returns a map from label names to LabelInfo values.
func (*Client) ChangeMessages ¶
func (c *Client) ChangeMessages(ch *Change) []*ChangeMessageInfo
ChangeMessages returns the messages on a Change. These are the top-level messages created by clicking on the top REPLY button when reviewing a change. Inline file comments are returned by Client.Comments.
func (*Client) ChangeNumber ¶
ChangeNumber returns the Gerrit change number. This is unique for a given Gerrit instance.
func (*Client) ChangeNumbers ¶
ChangeNumbers returns an iterator over the change numbers of a project. The first iterator value is the change number. The second iterator value is a function that can be called to return information about the change, as with storage.DB.Scan.
func (*Client) ChangeOwner ¶
func (c *Client) ChangeOwner(ch *Change) *AccountInfo
ChangeOwner returns the owner of the Gerrit change: the account that created the change.
func (*Client) ChangeProject ¶
Project returns the project that the change is in.
func (*Client) ChangeReviewers ¶
func (c *Client) ChangeReviewers(ch *Change) []*AccountInfo
ChangeReviewers returns a list of accounts that are listed as reviewers of this change. Note that this is not identical to ChangeInfo.Reviewers, which includes both reviewers and people CC'ed.
func (*Client) ChangeRevisions ¶
func (c *Client) ChangeRevisions(ch *Change) []*RevisionInfo
ChangeRevisions returns information about all the patch sets, ordered by patch set number.
func (*Client) ChangeStatus ¶
Status returns the status of the change: NEW, MERGED, ABANDONED.
func (*Client) ChangeSubject ¶
ChangeSubject returns the subject of a Change. This is the first line of the change description.
func (*Client) ChangeSubmitter ¶
func (c *Client) ChangeSubmitter(ch *Change) *AccountInfo
ChangeSubmitter returns the account that submitted the change. If the change has not been submitted this returns nil.
func (*Client) ChangeTimes ¶
func (c *Client) ChangeTimes(ch *Change) ChangeTimes
ChangeTimes returns the created, updated, submitted, and abandoned times for a change. If the change is not submitted or not abandoned, those times will be zero.
func (*Client) ChangeWatcher ¶
func (c *Client) ChangeWatcher(name string) *timed.Watcher[*ChangeEvent]
ChangeWatcher returns a new timed.Watcher with the given name. It picks up where any previous Watcher of the same name left odd.
func (*Client) ChangeWorkInProgress ¶
ChangeWorkInProgress reports whether the change is marked as work-in-progress.
func (*Client) Comments ¶
func (c *Client) Comments(project string, changeNum int) map[string][]*CommentInfo
Comments returns the comments on a change, if any. These are the inline comments placed on files in the change. The top-level replies are stored in a Change and are returned by Client.ChangeMessages.
This returns a map from file names to a list of comments on each file. The result is nil if no comment information exists.
func (*Client) DocWatcher ¶
func (c *Client) DocWatcher() *timed.Watcher[*ChangeEvent]
DocWatcher returns the change event watcher with name "gerritrelateddocs". Implements docs.Source.DocWatcher.
func (*Client) RequestFlush ¶
func (c *Client) RequestFlush()
RequestFlush asks a Gerrit sync to flush the database to disk when convenient. This may be called concurrently with Sync.
func (*Client) SyncProject ¶
SyncProject syncs a single project.
func (*Client) Testing ¶
func (c *Client) Testing() *TestingClient
Testing returns a TestingClient, which provides access to Client functionality intended for testing. Testing only returns a non-nil TestingClient in testing mode, which is active if the current program is a test binary (that is, testing.Testing returns true). Otherwise, Testing returns nil.
Each Client has only one TestingClient associated with it. Every call to Testing returns the same TestingClient.
func (*Client) ToDocs ¶
ToDocs converts a ChangeEvent to an embeddable document (wrapped as an iterator).
This document consists of a change commit message and its comments. The ID for such documents is of the form
https://<gerrit-instance>/c/<repo>/+/<n>#related-content.
The "#related-content" fragment is used to allow other types of gerrit documents to reuse the main portion of the change URL. The URL points to the top of the CL page since the fragment does not exist.
ToDocs returns (nil, false) if any of the necessary data cannot be found in the client's db.
Implements docs.Source.ToDocs.
type CommentInfo ¶
type CommentInfo struct { // The patch set number for the comment; only set in contexts // where comments may be returned for multiple patch sets. PatchSet int `json:"patch_set,omitempty"` // The URL encoded UUID of the comment. ID string `json:"id"` // The file path for which the inline comment was done. // Not set if returned in a map where the key is the file path. Path string `json:"path,omitempty"` // The side on which the comment was added. // Allowed values are REVISION and PARENT. // If not set, the default is REVISION. Side string `json:"side,omitempty"` // The 1-based parent number. Used only for merge commits when // side == PARENT. When not set the comment is for the // auto-merge tree. Parent int `json:"parent,omitempty"` // The number of the line for which the comment was done. // If range is set, this equals the end line of the range. // If neither line nor range is set, it’s a file comment. Line int `json:"line,omitempty"` // The range of the comment as a CommentRange entity. Range *CommentRange `json:"range,omitempty"` // The URL encoded UUID of the comment to which this comment is a reply. InReplyTo string `json:"in_reply_to,omitempty"` // The comment message. Message string `json:"message,omitempty"` // The timestamp of when this comment was written. Updated TimeStamp `json:"updated"` // The author of the message as an AccountInfo entity. // Unset for draft comments, assumed to be the calling user. Author *AccountInfo `json:"author,omitempty"` // Value of the tag field from ReviewInput set while posting // the review. Tag string `json:"tag,omitempty"` // Whether or not the comment must be addressed by the // user. The state of resolution of a comment thread is stored // in the last comment in that thread chronologically. Unresolved bool `json:"unresolved,omitempty"` // The id of the change message that this comment is linked to. ChangeMessageID string `json:"change_message_id,omitempty"` // Hex commit SHA-1 (40 characters string) of the commit of // the patchset to which this comment applies. CommitID string `json:"commit_id,omitempty"` // Suggested fixes for this comment. FixSuggestions []*FixSuggestionInfo `json:"fix_suggestions,omitempty"` }
CommentInfo holds information about an inline comment. This describes Gerrit JSON data.
type CommentRange ¶
type CommentRange struct { // The start line number of the range. (1-based) StartLine int `json:"start_line"` // The character position in the start line. (0-based) StartCharacter int `json:"start_character"` // The end line number of the range. (1-based) EndLine int `json:"end_line"` // The character position in the end line. (0-based) EndCharacter int `json:"end_character"` }
CommentRange describes the range of an inline comments. The comment range is a range from the start position, specified by start_line and start_character, to the end position, specified by end_line and end_character. The start position is inclusive and the end position is exclusive. This describes Gerrit JSON data.
type CommitInfo ¶
type CommitInfo struct { // The commit ID. Not set if included in a RevisionInfo entity // that is contained in a map which has the commit ID as key. Commit string `json:"commit,omitempty"` // The parent commits of this commit as a list of CommitInfo // entities. In each parent only the commit and subject fields // are populated. Parents []*CommitInfo `json:"parents,omitempty"` // The author of the commit as a GitPersonInfo entity. Author *GitPersonInfo `json:"author,omitempty"` // The committer of the commit as a GitPersonInfo entity. Committer *GitPersonInfo `json:"committer,omitempty"` // The subject of the commit (header line of the commit message). Subject string `json:"subject"` // The commit message. Message string `json:"message,omitempty"` // Links to the patch set in external sites as a list of // WebLinkInfo entities. WebLinks []*WebLinkInfo `json:"web_links,omitempty"` // Links to the commit in external sites for resolving // conflicts as a list of WebLinkInfo entities. ResolveConflictsWebLinks []*WebLinkInfo `json:"resolve_conflicts_web_links,omitempty"` }
CommitInfo holds information about a commit. This describes Gerrit JSON data.
type FixReplacementInfo ¶
type FixReplacementInfo struct { // The path of the file which should be modified. Any file in // the repository may be modified. The commit message can be // modified via the magic file /COMMIT_MSG though only the // part below the generated header of that magic file can be // modified. References to the header lines will result in // errors when the fix is applied. Path string `json:"path"` // A CommentRange indicating which content of the file should // be replaced. Lines in the file are assumed to be separated // by the line feed character. Range CommentRange `json:"range"` // The content which should be used instead of the current one. Replacement string `json:"replacement"` }
FixReplacementInfo describes how the content of a file should be replaced by another content. This describes Gerrit JSON data.
type FixSuggestionInfo ¶
type FixSuggestionInfo struct { // The UUID of the suggested fix. FixID string `json:"fix_id,omitempty"` // A description of the suggested fix. Description string `json:"description"` // A list of FixReplacementInfo entities indicating how the // content of one or several files should be modified. Within // a file, they should refer to non-overlapping regions. Replacements []*FixReplacementInfo `json:"replacements"` }
FixSuggestionInfo represents a suggested fix. This describes Gerrit JSON data.
type GitPersonInfo ¶
type GitPersonInfo struct { // The name of the author/committer. Name string `json:"name"` // The email address of the author/committer. Email string `json:"email"` // The timestamp of when this identity was constructed. Date TimeStamp `json:"date"` // The timezone offset from UTC of when this identity was constructed. TZ int `json:"tz"` }
GitPersonInfo holds information about the author/committer of a commit. This describes Gerrit JSON data.
type LabelInfo ¶
type LabelInfo struct { // Whether the label is optional. Optional means the label may // be set, but it’s neither necessary for submission nor does // it block submission if set. Optional bool `json:"optional,omitempty"` // The description of the label. Description string `json:"description,omitempty"` // One user who approved this label on the change (voted the // maximum value). Approved *AccountInfo `json:"approved,omitempty"` // One user who rejected this label on the change (voted the // minimum value) . Rejected *AccountInfo `json:"rejected,omitempty"` // One user who recommended this label on the change (voted // positively, but not the maximum value). Recommended *AccountInfo `json:"recommended,omitempty"` // One user who disliked this label on the change (voted // negatively, but not the minimum value). Disliked *AccountInfo `json:"disliked,omitempty"` // If true, the label blocks submit operation. Blocking bool `json:"blocking,omitempty"` // The voting value of the user who recommended/disliked this // label on the change if it is not “+1”/“-1”. Value int `json:"value,omitempty"` // The default voting value for the label. This value may be // outside the range specified in permitted_labels. DefaultValue int `json:"default_value,omitempty"` // A list of integers containing the vote values applied to // this label at the latest patchset. Votes []int `json:"votes,omitempty"` // List of all approvals for this label. Items in this list // may not represent actual votes cast by users; if a user // votes on any label, a corresponding ApprovalInfo will // appear in this list for all labels. All []*ApprovalInfo `json:"all,omitempty"` // A map of all values that are allowed for this label. The // map maps the values (“-2”, “-1”, " `0`", “+1”, “+2”) to the // value descriptions. Values map[string]string `json:"values,omitempty"` }
LabelInfo holds information about a label on a change, always corresponding to the current patch set. This describes Gerrit JSON data.
type ParentInfo ¶
type ParentInfo struct { // Name of the target branch into which the parent commit is merged. BranchName string `json:"branch_name,omitempty"` // The commit SHA-1 of the parent commit, or empty if the // current commit is root. CommitID string `json:"commit_id,omitempty"` // Set to true if the parent commit is merged into the target branch. IsMergedInTargetBranch bool `json:"is_merged_in_target_branch,omitempty"` // If the parent commit is a patch-set of another gerrit // change, this field will hold the change ID of the parent // change. Otherwise, will be empty. ChangeID string `json:"change_id,omitempty"` // If the parent commit is a patch-set of another gerrit // change, this field will hold the change number of the // parent change. Otherwise, will be zero. ChangeNumber int `json:"change_number,omitempty"` // If the parent commit is a patch-set of another gerrit // change, this field will hold the patch-set number of the // parent change. Otherwise, will be zero. PatchSetNumber int `json:"patch_set_number,omitempty"` // If the parent commit is a patch-set of another gerrit // change, this field will hold the change status of the // parent change. Otherwise, will be empty. ChangeStatus string `json:"change_status,omitempty"` }
ParentInfo holds information about the parent commit of a patch-set. This describes Gerrit JSON data.
type Requirement ¶
type Requirement struct { // Status of the requirement. Can be either OK, NOT_READY or RULE_ERROR. Status string `json:"status"` // A human readable reason. FallbackText string `json:"fallback_text"` // Alphanumerical (plus hyphens or underscores) string to // identify what the requirement is and why it was // triggered. Can be seen as a class: requirements sharing the // same type were created for a similar reason, and the data // structure will follow one set of rules. Type string `json:"type"` }
Requirement hold information about a requirement relative to a change. This describes Gerrit JSON data.
type RevisionInfo ¶
type RevisionInfo struct { // The change kind. Valid values are REWORK, TRIVIAL_REBASE, // TRIVIAL_REBASE_WITH_MESSAGE_UPDATE, MERGE_FIRST_PARENT_UPDATE, // NO_CODE_CHANGE, and NO_CHANGE. Kind string `json:"kind"` // The patch set number, or edit if the patch set is an edit. Number int `json:"_number"` // The timestamp of when the patch set was created. Created TimeStamp `json:"created"` // The uploader of the patch set as an AccountInfo entity. Uploader *AccountInfo `json:"uploader"` // The real uploader of the patch set as an AccountInfo entity. // Only set if the upload was done on behalf of another user. RealUploader *AccountInfo `json:"real_uploader,omitempty"` // The Git reference for the patch set. Ref string `json:"ref"` // The commit of the patch set as a CommitInfo entity. Commit *CommitInfo `json:"commit,omitempty"` // The parent commits of this patch-set commit as a list of // ParentInfo entities. In each parent, we include the target // branch name if the parent is a merged commit in the target // branch. Otherwise, we include the change and patch-set // numbers of the parent change. ParentsData []*ParentInfo `json:"parents_data,omitempty"` // The name of the target branch that this revision is set to // be merged into. Note that if the change is moved with the // Move Change endpoint, this field can be different for // different patchsets. For example, if the change is moved // and a new patchset is uploaded afterwards, the RevisionInfo // of the previous patchset will contain the old branch, but // the newer patchset will contain the new branch. Branch string `json:"branch,omitempty"` // The description of this patchset, as displayed in the // patchset selector menu. May be empty if no description is set. Description string `json:"description,omitempty"` }
RevisionInfo contains information about a patch set. This describes Gerrit JSON data.
type SubmitRecordInfo ¶
type SubmitRecordInfo struct { // The name of the submit rule that created this submit record. // The submit rule is specified in the form of "$plugin~$rule" // where $plugin is the plugin name and $rule is the name of // the class that implemented the submit rule. RuleName string `json:"rule_name"` // A list of labels, each containing the following fields. // * label: the label name. // * status: // * appliedBy: Labels []*struct { // The label name. Label string `json:"label"` // The label status: {OK, REJECT, MAY, NEED, IMPOSSIBLE}. Status string `json:"status"` // The account that applied the vote to the label. AppliedBy *AccountInfo `json:"appliedBy"` } `json:"labels,omitempty"` // List of the requirements to be met before this change can // be submitted. Requirements []*Requirement `json:"requirements,omitempty"` // When status is RULE_ERROR this message provides some text // describing the failure of the rule predicate. ErrorMessage string `json:"error_message,omitempty"` // contains filtered or unexported fields }
SubmitRecordInfo holds results from a submit rule. This describes Gerrit JSON data.
type TestingClient ¶
type TestingClient struct {
// contains filtered or unexported fields
}
A TestingClient provides access to Client functionality intended for testing.
func (*TestingClient) LoadTxtar ¶
func (tc *TestingClient) LoadTxtar(file string) error
LoadTxtar loads a change info history from the named txtar file, and adds it to tc.chs.
The file should contain a txtar archive (see golang.org/x/tools/txtar). Each file in the archive may be named “change#n” (for example “change#1”). A line in the file must be in the format "key: value", where "key" is one of the fields of ChangeInfo type.
func (*TestingClient) LoadTxtarData ¶
func (tc *TestingClient) LoadTxtarData(data []byte) error
LoadTxtarData loads a change info history from the txtar file content data. See [LoadTxtar] for a description of the format.
type TimeStamp ¶
TimeStamp adds Gerrit timestamp JSON marshaling and unmarshaling to a time.Time.
func (*TimeStamp) MarshalJSON ¶
MarshalJSON marshals a TimeStamp into JSON.
func (*TimeStamp) UnmarshalJSON ¶
UnmarshalJSON unmarshals JSON into a TimeStamp.
type VotingRangeInfo ¶
type VotingRangeInfo struct { // The minimum voting value. Min int `json:"min"` // The maximum voting value. Max int `json:"max"` }
VotingRangeInfo describes the continuous voting range from min to max values. This describes Gerrit JSON data.
type WebLinkInfo ¶
type WebLinkInfo struct { // The text to be linkified. Name string `json:"name"` // Tooltip to show when hovering over the link. Tooltip string `json:"tooltip,omitempty"` // The link URL. URL string `json:"url"` // URL to the icon of the link. ImageURL string `json:"image_url,omitempty"` }
WebLinkInfo describes a link to an external site. This describes Gerrit JSON data.