actions

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: Apache-2.0 Imports: 9 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) []string

ParseGHLabels parses the github labels into

Types

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) *Client

func (*Client) AutoLabel

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

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

func (*Client) BlockPRWith

func (c *Client) BlockPRWith(blockPRConfig BlockPRWith, owner, repoName string, prNumber int, prLbls []string) (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) GetCurrentLabels

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

GetCurrentLabels retrieve current labels of the given prNumber.

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) 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,
	prLbls []string,
) error

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

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 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"`
}

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