gerrit

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain struct {
	ChangeSets []*Changeset
}

Chain represents a list of successive changesets with an unbroken parent -> child relation, starting from the parent.

func AssembleChain

func AssembleChain(changesets []*Changeset, logger *log.Logger) ([]*Chain, error)

AssembleChain consumes a list of changesets, and groups them together to chains.

Initially, every changeset is put in its own individual chain.

we maintain a lookup table, mapLeafToChain, which allows to lookup a chain by its leaf commit id We concat chains in a fixpoint approach because both appending and prepending is much more complex. Concatenation moves changesets of the later changeset in the previous one in a cleanup phase, we remove orphaned chains (those without any changesets inside) afterwards, we do an integrity check, just to be on the safe side.

func SortChains

func SortChains(chains []*Chain) []*Chain

SortChains sorts a list of chains by the number of changesets in each chain, descending

func (*Chain) AllChangesets

func (s *Chain) AllChangesets(f func(c *Changeset) bool) bool

AllChangesets applies a filter function on all of the changesets in the chain. returns true if it returns true for all changesets, false otherwise

func (*Chain) GetLeafCommitID

func (s *Chain) GetLeafCommitID() (string, error)

GetLeafCommitID returns the commit id of the last commit in ChangeSets

func (*Chain) GetParentCommitIDs

func (s *Chain) GetParentCommitIDs() ([]string, error)

GetParentCommitIDs returns the parent commit IDs

func (*Chain) String

func (s *Chain) String() string

func (*Chain) Validate

func (s *Chain) Validate() error

Validate checks that the chain contains a properly ordered and connected chain of commits

type Changeset

type Changeset struct {
	ChangeID        string
	Number          int
	Verified        int
	CodeReviewed    int
	Autosubmit      int
	Submittable     bool
	CommitID        string
	ParentCommitIDs []string
	OwnerName       string
	Subject         string
	// contains filtered or unexported fields
}

Changeset represents a single changeset

func FilterChangesets

func FilterChangesets(changesets []*Changeset, f func(*Changeset) bool) []*Changeset

FilterChangesets filters a list of Changeset by a given filter function

func MakeChangeset

func MakeChangeset(changeInfo *goGerrit.ChangeInfo) *Changeset

MakeChangeset creates a new Changeset object out of a goGerrit.ChangeInfo object

func (*Changeset) IsAutosubmit

func (c *Changeset) IsAutosubmit() bool

IsAutosubmit returns true if the changeset is intended to be automatically submitted by gerrit-queue.

This is determined by the Change Owner setting +1 on the "Autosubmit" label.

func (*Changeset) IsCodeReviewed

func (c *Changeset) IsCodeReviewed() bool

IsCodeReviewed returns true if the changeset passed code review, that's when somebody left the Recommended (+2) on the "Code-Review" label

func (*Changeset) IsVerified

func (c *Changeset) IsVerified() bool

IsVerified returns true if the changeset passed CI, that's when somebody left the Approved (+1) on the "Verified" label

func (*Changeset) String

func (c *Changeset) String() string

type Client

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

Client provides some ways to interact with a gerrit instance

func NewClient

func NewClient(logger *log.Logger, URL, username, password, projectName, branchName string) (*Client, error)

NewClient initializes a new gerrit client

func (*Client) ChainIsRebasedOnHEAD

func (c *Client) ChainIsRebasedOnHEAD(chain *Chain) bool

ChainIsRebasedOnHEAD returns true if the whole chain is rebased on the current HEAD this is already the case if the first changeset in the chain is rebased on the current HEAD

func (*Client) ChangesetIsRebasedOnHEAD

func (c *Client) ChangesetIsRebasedOnHEAD(changeset *Changeset) bool

ChangesetIsRebasedOnHEAD returns true if the changeset is rebased on the current HEAD

func (*Client) FilterChains

func (c *Client) FilterChains(filter func(s *Chain) bool) []*Chain

FilterChains returns a subset of all chains, passing the given filter function

func (*Client) FindFirstChain

func (c *Client) FindFirstChain(filter func(s *Chain) bool) *Chain

FindFirstChain returns the first chain that matches the filter, or nil if none was found

func (*Client) GetBaseURL

func (c *Client) GetBaseURL() string

GetBaseURL returns the gerrit base URL

func (*Client) GetBranchName

func (c *Client) GetBranchName() string

GetBranchName returns the configured gerrit branch name

func (*Client) GetChangesetURL

func (c *Client) GetChangesetURL(changeset *Changeset) string

GetChangesetURL returns the URL to view a given changeset

func (*Client) GetHEAD

func (c *Client) GetHEAD() string

GetHEAD returns the internally stored HEAD

func (*Client) GetProjectName

func (c *Client) GetProjectName() string

GetProjectName returns the configured gerrit project name

func (*Client) RebaseChangeset

func (c *Client) RebaseChangeset(changeset *Changeset, ref string) (*Changeset, error)

RebaseChangeset rebases a given changeset on top of a given ref

func (*Client) Refresh

func (c *Client) Refresh() error

Refresh causes the client to refresh internal view of gerrit

func (*Client) SubmitChangeset

func (c *Client) SubmitChangeset(changeset *Changeset) (*Changeset, error)

SubmitChangeset submits a given changeset, and returns a changeset afterwards.

type IClient

type IClient interface {
	Refresh() error
	GetHEAD() string
	GetBaseURL() string
	GetChangesetURL(changeset *Changeset) string
	SubmitChangeset(changeset *Changeset) (*Changeset, error)
	RebaseChangeset(changeset *Changeset, ref string) (*Changeset, error)
	ChangesetIsRebasedOnHEAD(changeset *Changeset) bool
	ChainIsRebasedOnHEAD(chain *Chain) bool
	FilterChains(filter func(s *Chain) bool) []*Chain
	FindFirstChain(filter func(s *Chain) bool) *Chain
}

IClient defines the gerrit.Client interface

Jump to

Keyboard shortcuts

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