Documentation ¶
Index ¶
- Constants
- func GenerateTemplateOrFail(templ, name string, data interface{}) *string
- func GetMessage(ap Approvers, org, project string) *string
- func IntersectSetsCase(one, other sets.String) sets.String
- type Approval
- type ApprovedFile
- type Approvers
- func (ap *Approvers) AddApprover(login, reference string, noIssue bool)
- func (ap *Approvers) AddAssignees(logins ...string)
- func (ap *Approvers) AddAuthorSelfApprover(login, reference string)
- func (ap *Approvers) AddLGTMer(login, reference string, noIssue bool)
- func (ap Approvers) GetCCs() []string
- func (ap Approvers) GetCurrentApproversSet() sets.String
- func (ap Approvers) GetFiles(org, project string) []File
- func (ap Approvers) GetFilesApprovers() map[string]sets.String
- func (ap Approvers) GetNoIssueApproversSet() sets.String
- func (ap Approvers) IsApproved() bool
- func (ap Approvers) IsApprovedWithIssue() bool
- func (ap Approvers) ListApprovals() []Approval
- func (ap Approvers) ListNoIssueApprovals() []Approval
- func (ap Approvers) NoIssueApprovers() map[string]Approval
- func (ap *Approvers) RemoveApprover(login string)
- func (ap Approvers) UnapprovedFiles() sets.String
- type File
- type Owners
- func (o Owners) GetAllPotentialApprovers() []string
- func (o Owners) GetApprovers() map[string]sets.String
- func (o Owners) GetLeafApprovers() map[string]sets.String
- func (o Owners) GetOwnersSet() sets.String
- func (o Owners) GetReverseMap(approvers map[string]sets.String) map[string]sets.String
- func (o Owners) GetShuffledApprovers() []string
- func (o Owners) GetSuggestedApprovers(reverseMap map[string]sets.String, potentialApprovers []string) sets.String
- func (o Owners) KeepCoveringApprovers(reverseMap map[string]sets.String, knownApprovers sets.String, ...) sets.String
- type RepoAlias
- type RepoInterface
- type UnapprovedFile
Constants ¶
const (
ApprovalNotificationName = "ApprovalNotifier"
)
Variables ¶
This section is empty.
Functions ¶
func GenerateTemplateOrFail ¶
GenerateTemplateOrFail takes a template, name and data, and generates the corresping string. nil is returned if it fails. An error is logged.
func GetMessage ¶
getMessage returns the comment body that we want the approval-handler to display on PRs The comment shows:
- a list of approvers files (and links) needed to get the PR approved
- a list of approvers files with strikethroughs that already have an approver's approval
- a suggested list of people from each OWNERS files that can fully approve the PR
- how an approver can indicate their approval
- how an approver can cancel their approval
Types ¶
type Approval ¶
type Approval struct { Login string // Login of the approver How string // How did the approver approved Reference string // Where did the approver approved NoIssue bool // Approval also accepts missing associated issue }
Approval has the information about each approval on a PR
type ApprovedFile ¶
type ApprovedFile struct {
// contains filtered or unexported fields
}
func (ApprovedFile) String ¶
func (a ApprovedFile) String() string
type Approvers ¶
type Approvers struct { AssociatedIssue int // contains filtered or unexported fields }
func NewApprovers ¶
NewApprovers create a new "Approvers" with no approval.
func (*Approvers) AddApprover ¶
AddApprover adds a new Approver
func (*Approvers) AddAssignees ¶
AddAssignees adds assignees to the list
func (*Approvers) AddAuthorSelfApprover ¶
AddSAuthorSelfApprover adds the author self approval
func (Approvers) GetCCs ¶
GetCCs gets the list of suggested approvers for a pull-request. It now considers current assignees as potential approvers. Here is how it works: - We find suggested approvers from all potential approvers, but remove those that are not useful considering current approvers and assignees. This only uses leave approvers to find approvers the closest to the changes. - We find a subset of suggested approvers from from current approvers, suggested approvers and assignees, but we remove thoses that are not useful considering suggestd approvers and current approvers. This uses the full approvers list, and will result in root approvers to be suggested when they are assigned. We return the union of the two sets: suggested and suggested assignees. The goal of this second step is to only keep the assignees that are the most useful.
func (Approvers) GetCurrentApproversSet ¶
GetCurrentApproversSet returns the set of approvers (login only)
func (Approvers) GetFilesApprovers ¶
GetFilesApprovers returns a map from files -> list of current approvers.
func (Approvers) GetNoIssueApproversSet ¶
GetNoIssueApproversSet returns the set of "no-issue" approvers (login only)
func (Approvers) IsApproved ¶
IsApproved returns a bool indicating whether or not the PR is approved
func (Approvers) IsApprovedWithIssue ¶
IsApprovedWithIssue verifies that the PR is approved, and has an associated issue or a valid "no-issue" approver.
func (Approvers) ListApprovals ¶
ListApprovals returns the list of approvals
func (Approvers) ListNoIssueApprovals ¶
ListNoIssueApprovals returns the list of "no-issue" approvals
func (Approvers) NoIssueApprovers ¶
NoIssueApprovers returns the list of people who have "no-issue" approved the pull-request. They are included in the list iff they can approve one of the files.
func (*Approvers) RemoveApprover ¶
RemoveApprover removes an approver from the list.
func (Approvers) UnapprovedFiles ¶
UnapprovedFiles returns owners files that still need approval
type Owners ¶
type Owners struct {
// contains filtered or unexported fields
}
func (Owners) GetAllPotentialApprovers ¶
GetAllPotentialApprovers returns the people from relevant owners files needed to get the PR approved
func (Owners) GetApprovers ¶
GetApprovers returns a map from ownersFiles -> people that are approvers in them
func (Owners) GetLeafApprovers ¶
GetLeafApprovers returns a map from ownersFiles -> people that are approvers in them (only the leaf)
func (Owners) GetOwnersSet ¶
GetOwnersSet returns a set containing all the Owners files necessary to get the PR approved
func (Owners) GetReverseMap ¶
GetReverseMap returns a map from people -> OWNERS files for which they are an approver
func (Owners) GetShuffledApprovers ¶
Shuffles the potential approvers so that we don't always suggest the same people
func (Owners) GetSuggestedApprovers ¶
func (o Owners) GetSuggestedApprovers(reverseMap map[string]sets.String, potentialApprovers []string) sets.String
GetSuggestedApprovers solves the exact cover problem, finding an approver capable of approving every OWNERS file in the PR
func (Owners) KeepCoveringApprovers ¶
func (o Owners) KeepCoveringApprovers(reverseMap map[string]sets.String, knownApprovers sets.String, potentialApprovers []string) sets.String
KeepCoveringApprovers finds who we should keep as suggested approvers given a pre-selection knownApprovers must be a subset of potentialApprovers.
type RepoAlias ¶
type RepoAlias struct {
// contains filtered or unexported fields
}
func NewRepoAlias ¶
func NewRepoAlias(repo RepoInterface, alias features.Aliases) *RepoAlias
func (*RepoAlias) FindApproverOwnersForPath ¶
type RepoInterface ¶
type UnapprovedFile ¶
type UnapprovedFile struct {
// contains filtered or unexported fields
}
func (UnapprovedFile) String ¶
func (ua UnapprovedFile) String() string