actions

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHTTPErrorCode

func IsHTTPErrorCode(err error, httpCode int) bool

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the given error is a NotFound.

func ParseGHLabels

func ParseGHLabels(ghLabels []*gh.Label) map[string]struct{}

ParseGHLabels parses the github labels into a map of labels (a set)

Types

type AutoMerge added in v1.0.0

type AutoMerge struct {
	Label            string `yaml:"label"`
	MinimalApprovals int    `yaml:"min-approvals"`
}

type BlockPRWith

type BlockPRWith struct {
	// LabelsUnset blocks the PR if any of the Labels are not set, i.e., if any
	// of the regex does not match any label set in the PR.
	LabelsUnset []PRLabelConfig `yaml:"labels-unset,omitempty"`
	// LabelsSet blocks the PR if any of the Labels are set, i.e., if any of the
	// regex matches any label set in the PR.
	LabelsSet []PRLabelConfig `yaml:"labels-set,omitempty"`
}

type Client

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

func NewClient

func NewClient(ghClient *gh.Client, logger *zerolog.Logger) *Client

func (*Client) Assign added in v1.0.0

func (c *Client) Assign(ctx context.Context, owner string, name string, number int, users []*gh.User) (err error)

func (*Client) AutoLabel

func (c *Client) AutoLabel(labels []string, owner string, repoName string, prNumber int) error

AutoLabel sets the labels automatically in a PR that is opened or reopened.

func (*Client) AutoMerge added in v1.0.0

func (c *Client) AutoMerge(
	cfg AutoMerge,
	owner, repoName string,
	base,
	head *gh.PullRequestBranch,
	prNumber int,
	review *gh.PullRequestReview,
) error

func (*Client) BlockPRWith

func (c *Client) BlockPRWith(blockPRConfig BlockPRWith, owner, repoName string, prNumber int) (bool, []string, error)

BlockPRWith returns true if the PR needs to be blocked based on the logic stored under config.BlockPRWith.

func (*Client) CommitContains

func (c *Client) CommitContains(msgsInCommit []MsgInCommit, owner, repoName string, prNumber int) error

CommitContains checks if all commits of the given PR Number contains the each msg provided for each MsgInCommit.

func (*Client) FindPRInProject

func (c *Client) FindPRInProject(owner, repoName string, prNumber int, project Project) (int64, int64, error)

FindPRInProject finds the given PR number in the project. Returns the column and card ID for the given PR number. If not found, returns 0.

func (*Client) GetColumnID

func (c *Client) GetColumnID(owner, repoName string, project Project) (int64, int64, error)

GetColumnID returns the ProjectID and ColumnID for the given Project.

func (*Client) GetOrCreateColumnID

func (c *Client) GetOrCreateColumnID(owner, repoName string, proj Project) (int64, error)

GetOrCreateColumnID returns the column ID for the given project. If the column is not found in the project then it will be automatically created.

func (*Client) HandlePRE

func (c *Client) HandlePRE(cfg PRBlockerConfig, pre *gh.PullRequestEvent) error

func (*Client) HandlePRRE added in v1.0.0

func (c *Client) HandlePRRE(cfg PRBlockerConfig, pre *gh.PullRequestReviewEvent) error

func (*Client) HandleSE added in v1.0.0

func (c *Client) HandleSE(cfg PRBlockerConfig, se *gh.StatusEvent) error

func (*Client) PutPRInProject

func (c *Client) PutPRInProject(owner, repoName string, prID int64, project Project) error

PutPRInProject puts the given prID (not PR number) into the given project.

func (*Client) SyncPRProjects

func (c *Client) SyncPRProjects(
	moveToProjectsForLabelsXORed map[string]map[string]Project,
	owner,
	repoName string,
	prID int64,
	prNumber int,
) error

SyncPRProjects syncs the given prID (not PR Number) across all projects defined in the moveToProjectsForLabelsXORed

func (*Client) Unassign added in v1.0.1

func (c *Client) Unassign(ctx context.Context, owner string, name string, number int, users []*gh.User) (err error)

func (*Client) UpdateMergeabilityCheck

func (c *Client) UpdateMergeabilityCheck(
	owner string,
	repoName string,
	prNumber int,
	head *gh.PullRequestBranch,
	blockPR bool,
	blockReasons []string,
) error

UpdateMergeabilityCheck sets the mergeability checker with "Success" or "Failure" in case the PR needs to be blocked from mergeability.

type ErrProjectNotFound added in v1.0.0

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

func (ErrProjectNotFound) Error added in v1.0.0

func (e ErrProjectNotFound) Error() string

func (*ErrProjectNotFound) Is added in v1.0.0

func (e *ErrProjectNotFound) Is(target error) bool

type MsgInCommit

type MsgInCommit struct {
	// Msg is the message that should be found in the commit message.
	Msg string `yaml:"msg,omitempty"`
	// Helper is the message that should be printed if 'Msg' is not found in
	// the commit message.
	Helper string `yaml:"helper,omitempty"`
	// SetLabels are the labels to be set in the PR for which Msg was not found.
	SetLabels []string `yaml:"set-labels,omitempty"`
}

type PRBlockerConfig

type PRBlockerConfig struct {
	Project                      `yaml:",inline"`
	MoveToProjectsForLabelsXORed map[string]map[string]Project `yaml:"move-to-projects-for-labels-xored,omitempty"`
	RequireMsgsInCommit          []MsgInCommit                 `yaml:"require-msgs-in-commit,omitempty"`
	AutoLabel                    []string                      `yaml:"auto-label,omitempty"`
	BlockPRWith                  BlockPRWith                   `yaml:"block-pr-with,omitempty"`
	AutoMerge                    AutoMerge                     `yaml:"auto-merge,omitempty"`
}

type PRLabelConfig

type PRLabelConfig struct {
	// RegexLabel contains the regex that will be used to find for labels.
	RegexLabel string `yaml:"regex-label,omitempty"`
	// Helper will print the a helper message in case the regex-label is or
	// isn't matched.
	Helper string `yaml:"helper,omitempty"`
	// SetLabels will set the labels in case the RegexLabel matches the labels
	// of a PR.
	SetLabels []string `yaml:"set-labels,omitempty"`
}

type Project

type Project struct {
	ProjectName string `yaml:"project,omitempty"`
	ColumnName  string `yaml:"column,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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