Documentation
¶
Overview ¶
Package gerritsdk provides a high-level Go client for Gerrit Code Review instances, with first-class support for Googlesource.com authentication.
Index ¶
- func ParseGitCookiesForHost(path, host string) (user, pass string, err error)deprecated
- type AuthMethoddeprecated
- type BearerTokenAuth
- type BuildQuery
- func NewQuery() *BuildQuerydeprecated
- func (q *BuildQuery) After(t time.Time) *BuildQuery
- func (q *BuildQuery) Before(t time.Time) *BuildQuery
- func (q *BuildQuery) File(path string) *BuildQuery
- func (q *BuildQuery) Owner(user string) *BuildQuery
- func (q *BuildQuery) Project(name string) *BuildQuery
- func (q *BuildQuery) Raw(fragment string) *BuildQuery
- func (q *BuildQuery) Status(status string) *BuildQuery
- func (q *BuildQuery) String() string
- type CL
- type CLFile
- type Clientdeprecated
- func (c *Client) GetChangeCommitMessage(ctx context.Context, changeID string) (string, error)
- func (c *Client) GetChangeDetail(ctx context.Context, changeID string) (*CL, error)
- func (c *Client) GetChangeDiff(ctx context.Context, changeID, filePath string) (*FileDiff, error)
- func (c *Client) GetChangeFiles(ctx context.Context, changeID string) ([]CLFile, error)
- func (c *Client) GetProject(ctx context.Context, name string) (*Project, error)
- func (c *Client) Host() string
- func (c *Client) Inner() *gogerrit.Client
- func (c *Client) ListProjectBranches(ctx context.Context, project string) ([]string, error)
- func (c *Client) ListProjects(ctx context.Context) ([]Project, error)
- func (c *Client) QueryChanges(ctx context.Context, query string, opts ...QueryOption) ([]CL, error)
- type DiffContent
- type FileDiff
- type GitCookiesAuthdeprecated
- type HTTPBasicAuth
- type Link
- type Option
- type Project
- type QueryOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseGitCookiesForHost
deprecated
ParseGitCookiesForHost reads a .gitcookies file and returns credentials for the specified host.
Deprecated: this module is unmaintained, and this function does not work on the .gitcookies file Google actually issues. It matches only an exact host or "."+host, so the fleet-wide ".googlesource.com" line never matches a specific review host such as "chromium-review.googlesource.com". It also ignores the includeSubdomains field, never inspects the cookie name, and never checks expiry. See the README.
Types ¶
type AuthMethod
deprecated
type AuthMethod interface {
// contains filtered or unexported methods
}
AuthMethod configures how the client authenticates with Gerrit.
Deprecated: this module is unmaintained. See the README.
type BearerTokenAuth ¶
type BearerTokenAuth struct {
Token string
}
BearerTokenAuth authenticates with an OAuth2 bearer token.
type BuildQuery ¶
type BuildQuery struct {
// contains filtered or unexported fields
}
BuildQuery is a helper for constructing Gerrit query strings.
func NewQuery
deprecated
func NewQuery() *BuildQuery
NewQuery starts building a query.
Deprecated: this module is unmaintained. The builder does not quote values, so any value containing a space is silently split into two query terms, and callers can inject arbitrary Gerrit operators through Project, Owner or File. See the README.
func (*BuildQuery) After ¶
func (q *BuildQuery) After(t time.Time) *BuildQuery
After restricts to changes updated after a time.
func (*BuildQuery) Before ¶
func (q *BuildQuery) Before(t time.Time) *BuildQuery
Before restricts to changes updated before a time.
func (*BuildQuery) File ¶
func (q *BuildQuery) File(path string) *BuildQuery
File restricts to changes touching a file path (prefix match).
func (*BuildQuery) Owner ¶
func (q *BuildQuery) Owner(user string) *BuildQuery
Owner restricts to changes owned by a user.
func (*BuildQuery) Project ¶
func (q *BuildQuery) Project(name string) *BuildQuery
Project restricts to a project.
func (*BuildQuery) Raw ¶
func (q *BuildQuery) Raw(fragment string) *BuildQuery
Raw adds a raw query fragment.
func (*BuildQuery) Status ¶
func (q *BuildQuery) Status(status string) *BuildQuery
Status restricts to a change status.
func (*BuildQuery) String ¶
func (q *BuildQuery) String() string
String returns the assembled query.
type CL ¶
type CL struct {
Number int `json:"number"`
Project string `json:"project"`
Branch string `json:"branch"`
ChangeID string `json:"change_id"`
Subject string `json:"subject"`
Status string `json:"status"` // NEW, MERGED, ABANDONED
Owner string `json:"owner"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Submitted time.Time `json:"submitted,omitempty"`
Mergeable bool `json:"mergeable,omitempty"`
URL string `json:"url"`
Files []string `json:"files,omitempty"`
}
CL represents a Gerrit change (changelist).
type CLFile ¶
type CLFile struct {
Path string `json:"path"`
Status string `json:"status"` // ADDED, MODIFIED, DELETED, RENAMED, COPIED
OldPath string `json:"old_path,omitempty"`
Insertions int `json:"insertions"`
Deletions int `json:"deletions"`
}
CLFile represents a file changed in a CL revision.
type Client
deprecated
type Client struct {
// contains filtered or unexported fields
}
Client is a high-level Gerrit REST API client.
Deprecated: this module is unmaintained and has known defects that produce silently wrong results. See the README.
func NewAnonymousClient
deprecated
NewAnonymousClient creates an unauthenticated Gerrit client. Only public endpoints will be accessible.
Deprecated: this module is unmaintained. NewAnonymousClient also accepts and silently discards WithAuth, so a caller who passes a credential here gets anonymous requests with no error. See the README.
func NewClient
deprecated
NewClient creates a Gerrit client for the given host. The host should be a bare hostname like "bazel-review.googlesource.com".
Deprecated: this module is unmaintained. NewClient also mutates the http.Client passed via WithHTTPClient, so two clients built from one http.Client stack auth transports and send both credentials. See the README.
func (*Client) GetChangeCommitMessage ¶
GetChangeCommitMessage returns the commit message for a change.
func (*Client) GetChangeDetail ¶
GetChangeDetail returns detailed information about a single change.
func (*Client) GetChangeDiff ¶
GetChangeDiff returns the diff for a specific file in a change.
func (*Client) GetChangeFiles ¶
GetChangeFiles returns the list of files modified in the current patchset.
func (*Client) GetProject ¶
GetProject returns details about a specific project.
func (*Client) ListProjectBranches ¶
ListProjectBranches returns branches for a project.
func (*Client) ListProjects ¶
ListProjects returns all projects on the Gerrit instance.
func (*Client) QueryChanges ¶
QueryChanges searches for changes matching the given Gerrit query string. Example queries:
"project:bazel status:merged file:docs/" "status:open owner:self"
type DiffContent ¶
type DiffContent struct {
Common []string `json:"ab,omitempty"` // lines common to both
OldOnly []string `json:"a,omitempty"` // lines only in old version
NewOnly []string `json:"b,omitempty"` // lines only in new version
}
DiffContent represents a segment of a unified diff returned by Gerrit.
type FileDiff ¶
type FileDiff struct {
Path string `json:"path"`
Content []DiffContent `json:"content"`
}
FileDiff represents the diff for a single file.
type GitCookiesAuth
deprecated
type GitCookiesAuth struct {
Path string // path to .gitcookies file; empty = ~/.gitcookies
}
GitCookiesAuth authenticates using a .gitcookies file, the standard method for googlesource.com instances.
Deprecated: this module is unmaintained, and this type is the worst defect in it. Apply never receives the target host, so it calls parseGitCookies, which returns the FIRST googlesource credential in the file regardless of which host the request is for — it will send one review host's identity to another. It also does no tilde expansion, so a literal "~/.gitcookies" Path fails to open. See the README.
type HTTPBasicAuth ¶
HTTPBasicAuth authenticates with a username and password/token.
type Option ¶
type Option func(*clientConfig)
Option configures a Client.
func WithHTTPClient ¶
WithHTTPClient sets a custom http.Client for the underlying transport.
type Project ¶
type Project struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
State string `json:"state"` // ACTIVE, READ_ONLY, HIDDEN
WebLinks []Link `json:"web_links,omitempty"`
}
Project represents a Gerrit project (repository).
type QueryOption ¶
type QueryOption func(*queryConfig)
QueryOption modifies a change query.
func WithFields ¶
func WithFields(fields ...string) QueryOption
WithFields requests additional fields (e.g. "CURRENT_REVISION", "ALL_FILES").
func WithOffset ¶
func WithOffset(n int) QueryOption
WithOffset sets the result offset for pagination.