Documentation ¶
Overview ¶
Package gerrit contains functions for interacting with gerrit/gitiles.
Package gerrit contains functions for interacting with gerrit/gitiles.
Copyright 2021 The Chromium OS Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
- Variables
- func Branches(ctx context.Context, authedClient *http.Client, host, project string) (map[string]string, error)
- func DownloadFileFromGitiles(ctx context.Context, authedClient *http.Client, ...) (string, error)
- func DownloadFileFromGitilesToPath(ctx context.Context, authedClient *http.Client, ...) error
- func DownloadFileRequestEq(req *gitilespb.DownloadFileRequest) gomock.Matcher
- func FetchFilesFromGitiles(ctx context.Context, authedClient *http.Client, host, project, ref string, ...) (*map[string]string, error)
- func Projects(ctx context.Context, authedClient *http.Client, host string) ([]string, error)
- func RefsRequestEq(req *gitilespb.RefsRequest) gomock.Matcher
- type ChangeRev
- type ChangeRevData
- type ChangeRevKey
- type DownloadFileRequestMatcher
- type RefsRequestMatcher
Constants ¶
This section is empty.
Variables ¶
var ( // MockGitiles is used for testing purposes. // Override this to use a mock GitilesClient rather than the real one. MockGitiles gitilespb.GitilesClient )
Functions ¶
func Branches ¶
func Branches(ctx context.Context, authedClient *http.Client, host, project string) (map[string]string, error)
Branches returns a map of branches (to revisions) for a given repo.
func DownloadFileFromGitiles ¶
func DownloadFileFromGitiles(ctx context.Context, authedClient *http.Client, host, project, ref, path string) (string, error)
DownloadFileFromGitiles downloads a file from Gitiles.
func DownloadFileFromGitilesToPath ¶
func DownloadFileFromGitilesToPath(ctx context.Context, authedClient *http.Client, host, project, ref, path, saveToPath string) error
DownloadFileFromGitilesToPath downloads a file from Gitiles to a specified path.
func DownloadFileRequestEq ¶
func DownloadFileRequestEq(req *gitilespb.DownloadFileRequest) gomock.Matcher
func FetchFilesFromGitiles ¶
func FetchFilesFromGitiles(ctx context.Context, authedClient *http.Client, host, project, ref string, paths []string) (*map[string]string, error)
FetchFilesFromGitiles fetches file contents from gitiles.
project is the git project to fetch from. ref is the git-ref to fetch from. paths lists the paths inside the git project to fetch contents for.
fetchFilesFromGitiles returns a map from path in the git project to the contents of the file at that path for each requested path.
func RefsRequestEq ¶
func RefsRequestEq(req *gitilespb.RefsRequest) gomock.Matcher
Types ¶
type ChangeRev ¶
type ChangeRev struct { ChangeRevKey Project string // Ref that this change targets, e.g.: "refs/heads/main" Branch string // The Git reference for the patch set, e.g. "refs/changes/23/123/5" Ref string Files []string }
ChangeRev contains data about a Gerrit change,revision pair.
type ChangeRevData ¶
type ChangeRevData struct {
// contains filtered or unexported fields
}
ChangeRevData encapsulates a bunch of Gerrit change revisions.
func GetChangeRevData ¶
func GetChangeRevData(ctx context.Context, authedClient *http.Client, changeIds []ChangeRevKey) (*ChangeRevData, error)
GetChangeRevData fetches the Gerrit changes for the provided ChangeIdKeys, and bundles the result into a ChangeRevData.
func GetChangeRevsForTest ¶
func GetChangeRevsForTest(cr []*ChangeRev) *ChangeRevData
GetChangeRevsForTest is intended for testing only, and it allows creation of a ChangeRevData through the supplied ChangeRevs.
func (ChangeRevData) GetChangeRev ¶
func (crv ChangeRevData) GetChangeRev(host string, changeNum int64, revision int32) (*ChangeRev, error)
GetChangeRev extracts a single Gerrit change revision from the ChangeRevData.
type ChangeRevKey ¶
ChangeRevKey is the necessary set of data for looking up a single Gerrit revision.
func ParseCLURL ¶
func ParseCLURL(rawurl string) (*ChangeRevKey, error)
ParseCLURL parses a url for a CL into a ChangeRevKey.
The url must be of the form: "https://<host>-review.googlesource.com/c/<project>/+/<change number>/<patchset>".
func (ChangeRevKey) String ¶
func (cik ChangeRevKey) String() string
type DownloadFileRequestMatcher ¶
type DownloadFileRequestMatcher struct {
// contains filtered or unexported fields
}
Native gomock.Eq does not work on protos.
func (DownloadFileRequestMatcher) Matches ¶
func (m DownloadFileRequestMatcher) Matches(x interface{}) bool
func (DownloadFileRequestMatcher) String ¶
func (m DownloadFileRequestMatcher) String() string
type RefsRequestMatcher ¶
type RefsRequestMatcher struct {
// contains filtered or unexported fields
}
func (RefsRequestMatcher) Matches ¶
func (m RefsRequestMatcher) Matches(x interface{}) bool
func (RefsRequestMatcher) String ¶
func (m RefsRequestMatcher) String() string