requirements

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LabelApply will place the label on the PR if it doesn't exist.
	LabelApply = iota
	// LabelRemove will remove the label from the PR if it exists.
	LabelRemove
	// LabelIgnore always leaves the label on the PR as-is, without modifying it.
	LabelIgnore
)
View Source
const PR_BASE = "PR_BASE"

Pass this to UpToDateWith constructor to check the PR head branch against its base branch.

Variables

This section is empty.

Functions

This section is empty.

Types

type IfCondition

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

IfCondition executes the condition, and based on the result then runs Then or Else.

func If

func If(cond Requirement) *IfCondition

If returns a conditional requirement, which runs Then if cond evaluates successfully, or Else otherwise.

Then / Else are optional, and always evaluate to true by default.

func (*IfCondition) Else

func (i *IfCondition) Else(els Requirement) *IfCondition

func (*IfCondition) IsSatisfied

func (i *IfCondition) IsSatisfied(pr *github.PullRequest, details treeprint.Tree) bool

func (*IfCondition) Then

func (i *IfCondition) Then(then Requirement) *IfCondition

type LabelAction

type LabelAction byte

LabelAction controls what to do with the given label.

type Requirement

type Requirement interface {
	// Check if the Requirement is satisfied and add the detail
	// to the tree passed as a parameter.
	IsSatisfied(pr *github.PullRequest, details treeprint.Tree) bool
}

func Always

func Always() Requirement

func And

func And(requirements ...Requirement) Requirement

func Assignee

func Assignee(gh *client.GitHub, user string) Requirement

func Author

func Author(user string) Requirement

func AuthorInTeam

func AuthorInTeam(gh *client.GitHub, team string) Requirement

func Draft

func Draft() Requirement

func Label

func Label(gh *client.GitHub, name string, action LabelAction) Requirement

Label asserts that the label with the given name is not applied to the PR.

If it's not a dry run, the label will be applied to the PR.

func MaintainerCanModify

func MaintainerCanModify() Requirement

func Never

func Never() Requirement

func Not

func Not(req Requirement) Requirement

func Or

func Or(requirements ...Requirement) Requirement

func UpToDateWith

func UpToDateWith(gh *client.GitHub, base string) Requirement

type ReviewByOrgMembersRequirement

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

ReviewByOrgMembersRequirement asserts that the given PR has been reviewed by at least count members of the given organization, filtering for PR reviews with state desiredState.

func ReviewByOrgMembers

func ReviewByOrgMembers(gh *client.GitHub) *ReviewByOrgMembersRequirement

ReviewByOrgMembers asserts that at least 1 member of the organization reviewed this PR.

func (*ReviewByOrgMembersRequirement) IsSatisfied

func (r *ReviewByOrgMembersRequirement) IsSatisfied(pr *github.PullRequest, details treeprint.Tree) bool

IsSatisfied implements Requirement.

func (*ReviewByOrgMembersRequirement) WithCount

WithCount specifies the number of required reviews. By default, this is 1.

func (*ReviewByOrgMembersRequirement) WithDesiredState

WithDesiredState asserts that the reviews should also be of the given ReviewState.

If an empty string is passed, then all reviews are counted. This is the default.

type ReviewByTeamMembersRequirement

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

ReviewByTeamMembersRequirement asserts that count members of the given team have reviewed the PR. Additionally, using desiredState, it may be required that the PR reviews be of that state.

func ReviewByTeamMembers

func ReviewByTeamMembers(gh *client.GitHub, team string) *ReviewByTeamMembersRequirement

ReviewByTeamMembers specifies that the given pull request should receive at least one review from a member of the given team.

The number of required reviews, or the state of the reviews (e.g., to filter only for approval reviews) can be modified using WithCount and WithDesiredState.

func (*ReviewByTeamMembersRequirement) IsSatisfied

func (r *ReviewByTeamMembersRequirement) IsSatisfied(pr *github.PullRequest, details treeprint.Tree) bool

IsSatisfied implements Requirement.

func (*ReviewByTeamMembersRequirement) WithCount

WithCount specifies the number of required reviews. By default, this is 1.

func (*ReviewByTeamMembersRequirement) WithDesiredState

WithDesiredState asserts that the reviews should also be of the given ReviewState.

If an empty string is passed, then all reviews are counted. This is the default.

type ReviewByUserRequirement

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

ReviewByUserRequirement asserts that there is a review by the given user, and if given that the review matches the desiredState.

func ReviewByUser

func ReviewByUser(gh *client.GitHub, user string) *ReviewByUserRequirement

ReviewByUser asserts that the PR has been reviewed by the given user.

func (*ReviewByUserRequirement) IsSatisfied

func (r *ReviewByUserRequirement) IsSatisfied(pr *github.PullRequest, details treeprint.Tree) bool

IsSatisfied implements Requirement.

func (*ReviewByUserRequirement) WithDesiredState

WithDesiredState asserts that the review by the given user should also be of the given ReviewState.

If an empty string is passed, then all reviews are counted. This is the default.

Jump to

Keyboard shortcuts

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