Documentation
¶
Index ¶
- Constants
- type IfCondition
- type LabelAction
- type Requirement
- func Always() Requirement
- func And(requirements ...Requirement) Requirement
- func Assignee(gh *client.GitHub, user string) Requirement
- func Author(user string) Requirement
- func AuthorInTeam(gh *client.GitHub, team string) Requirement
- func Draft() Requirement
- func Label(gh *client.GitHub, name string, action LabelAction) Requirement
- func MaintainerCanModify() Requirement
- func Never() Requirement
- func Not(req Requirement) Requirement
- func Or(requirements ...Requirement) Requirement
- func UpToDateWith(gh *client.GitHub, base string) Requirement
- type ReviewByOrgMembersRequirement
- func (r *ReviewByOrgMembersRequirement) IsSatisfied(pr *github.PullRequest, details treeprint.Tree) bool
- func (r *ReviewByOrgMembersRequirement) WithCount(n uint) *ReviewByOrgMembersRequirement
- func (r *ReviewByOrgMembersRequirement) WithDesiredState(s utils.ReviewState) *ReviewByOrgMembersRequirement
- type ReviewByTeamMembersRequirement
- func (r *ReviewByTeamMembersRequirement) IsSatisfied(pr *github.PullRequest, details treeprint.Tree) bool
- func (r *ReviewByTeamMembersRequirement) WithCount(n uint) *ReviewByTeamMembersRequirement
- func (r *ReviewByTeamMembersRequirement) WithDesiredState(s utils.ReviewState) *ReviewByTeamMembersRequirement
- type ReviewByUserRequirement
Constants ¶
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 )
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 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 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 ¶
func (r *ReviewByOrgMembersRequirement) WithCount(n uint) *ReviewByOrgMembersRequirement
WithCount specifies the number of required reviews. By default, this is 1.
func (*ReviewByOrgMembersRequirement) WithDesiredState ¶
func (r *ReviewByOrgMembersRequirement) WithDesiredState(s utils.ReviewState) *ReviewByOrgMembersRequirement
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 ¶
func (r *ReviewByTeamMembersRequirement) WithCount(n uint) *ReviewByTeamMembersRequirement
WithCount specifies the number of required reviews. By default, this is 1.
func (*ReviewByTeamMembersRequirement) WithDesiredState ¶
func (r *ReviewByTeamMembersRequirement) WithDesiredState(s utils.ReviewState) *ReviewByTeamMembersRequirement
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 ¶
func (r *ReviewByUserRequirement) WithDesiredState(s utils.ReviewState) *ReviewByUserRequirement
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.