client

package
v0.0.0-...-28799ed Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package client implements a client that can handle multiple gerrit instances derived from https://github.com/andygrunwald/go-gerrit

Package client implements client that interacts with gerrit instances

Index

Constants

View Source
const (
	// CodeReview is the default (soon to be removed) gerrit code review label
	CodeReview = "Code-Review"

	// Merged status indicates a Gerrit change has been merged
	Merged = "MERGED"
	// New status indicates a Gerrit change is new (ie pending)
	New = "NEW"

	// ReadyForReviewMessage are the messages for a Gerrit change if it's changed
	// from Draft to Active.
	// This message will be sent if users press the `MARK AS ACTIVE` button.
	ReadyForReviewMessageFixed = "Set Ready For Review"
	// This message will be sent if users press the `SEND AND START REVIEW` button.
	ReadyForReviewMessageCustomizable = "This change is ready for review."

	ResultError   = "ERROR"
	ResultSuccess = "SUCCESS"
)

Variables

This section is empty.

Functions

func ChangedFilesProvider

func ChangedFilesProvider(changeInfo *ChangeInfo) config.ChangedFilesProvider

ChangedFilesProvider lists (in lexicographic order) the files changed as part of a Gerrit patchset. It includes the original paths of renamed files.

Types

type ChangeInfo

type ChangeInfo = gerrit.ChangeInfo

ChangeInfo is a gerrit.ChangeInfo

type Client

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

Client holds a instance:handler map

func NewClient

func NewClient(instances map[string]map[string]*config.GerritQueryFilter, maxQPS, maxBurst int) (*Client, error)

NewClient returns a new gerrit client

func (*Client) Account

func (c *Client) Account(instance string) (*gerrit.AccountInfo, error)

Account returns gerrit account for the given instance

func (*Client) ApplyGlobalConfig

func (c *Client) ApplyGlobalConfig(orgRepoConfigGetter func() *config.GerritOrgRepoConfigs, lastSyncTracker *SyncTime, cookiefilePath, tokenPathOverride string, additionalFunc func())

func (*Client) Authenticate

func (c *Client) Authenticate(cookiefilePath, tokenPath string)

Authenticate client calls using the specified file. Periodically re-reads the file to check for an updated value. cookiefilePath takes precedence over tokenPath if both are set.

func (*Client) ChangeExist

func (c *Client) ChangeExist(instance, id string) (bool, error)

func (*Client) GetBranchRevision

func (c *Client) GetBranchRevision(instance, project, branch string) (string, error)

GetBranchRevision returns SHA of HEAD of a branch

func (*Client) GetChange

func (c *Client) GetChange(instance, id string, addtionalFields ...string) (*ChangeInfo, error)

func (*Client) GetMergeableInfo

func (c *Client) GetMergeableInfo(instance, changeID, revisionID string) (*gerrit.MergeableInfo, error)

func (*Client) HasRelatedChanges

func (c *Client) HasRelatedChanges(instance, id, revision string) (bool, error)

HasRelatedChanges determines if the specified change is part of a chain. In other words, it determines if this change depends on any other changes or if any other changes depend on this change.

func (*Client) QueryChanges

func (c *Client) QueryChanges(lastState LastSyncState, rateLimit int) map[string][]ChangeInfo

QueryChanges queries for all changes from all projects after lastUpdate time returns an instance:changes map

func (*Client) QueryChangesForInstance

func (c *Client) QueryChangesForInstance(instance string, lastState LastSyncState, rateLimit int) []ChangeInfo

func (*Client) QueryChangesForProject

func (c *Client) QueryChangesForProject(instance, project string, lastUpdate time.Time, rateLimit int, additionalFilters ...string) ([]ChangeInfo, error)

QueryChangesForProject queries change for a project.

Important: this method does not update LastSyncState as it is per instance based. It doesn't make sense to update the state as this method has no idea whether all other projects have been queries or not yet. So caller of this method is responsible for making sure that LastSyncState is up-to-date, if the lastUpdate time is used by caller.

func (*Client) SetReview

func (c *Client) SetReview(instance, id, revision, message string, labels map[string]string) error

SetReview writes a review comment base on the change id + revision

func (*Client) SubmitChange

func (c *Client) SubmitChange(instance, id string, wait bool) (*ChangeInfo, error)

func (*Client) UpdateClients

func (c *Client) UpdateClients(instances map[string]map[string]*config.GerritQueryFilter) error

UpdateClients update gerrit clients with new instances map

type FileInfo

type FileInfo = gerrit.FileInfo

FileInfo is a gerrit.FileInfo

type LastSyncState

type LastSyncState map[string]map[string]time.Time

Map from instance name to repos to lastsync time for that repo

func (LastSyncState) DeepCopy

func (l LastSyncState) DeepCopy() LastSyncState

type RevisionInfo

type RevisionInfo = gerrit.RevisionInfo

RevisionInfo is a gerrit.RevisionInfo

type SyncTime

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

func NewSyncTime

func NewSyncTime(path string, opener opener, ctx context.Context) *SyncTime

func (*SyncTime) Current

func (st *SyncTime) Current() LastSyncState

func (*SyncTime) Init

func (st *SyncTime) Init(hostProjects map[string]map[string]*config.GerritQueryFilter) error

func (*SyncTime) Update

func (st *SyncTime) Update(newState LastSyncState) error

Jump to

Keyboard shortcuts

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