Documentation ¶
Overview ¶
Package ghpr is an abstraction around GitHub's Pull Request.
Index ¶
- type PullRequest
- func (pr *PullRequest) BaseBranch() string
- func (pr *PullRequest) LocalRepo() string
- func (pr *PullRequest) Metadata() *github.PullRequest
- func (pr *PullRequest) Patches() []*patch.Patch
- func (pr *PullRequest) SatisfiesMergeRequirements(ctx context.Context, opts ...PullRequestMergableOption) (bool, map[string][]string, error)
- func (pr *PullRequest) Workdir() string
- type PullRequestMergableOption
- func WithApproveStates(approveStates ...string) PullRequestMergableOption
- func WithApproverComments(approverComments ...string) PullRequestMergableOption
- func WithApproverTeams(approverTeams ...string) PullRequestMergableOption
- func WithIgnoreLabels(ignoreLabels ...string) PullRequestMergableOption
- func WithIgnoreStates(ignoreStates ...string) PullRequestMergableOption
- func WithLabels(labels ...string) PullRequestMergableOption
- func WithMinApprovals(minApprovals int) PullRequestMergableOption
- func WithMinReviews(minReviews int) PullRequestMergableOption
- func WithNoConflicts(noConflicts bool) PullRequestMergableOption
- func WithNoDraft(noDraft bool) PullRequestMergableOption
- func WithNoRespectAssignees(noRespectAssignees bool) PullRequestMergableOption
- func WithNoRespectReviewers(noRespectReviewers bool) PullRequestMergableOption
- func WithReviewStates(reviewStates ...string) PullRequestMergableOption
- func WithReviewerComments(reviewerComments ...string) PullRequestMergableOption
- func WithReviewerTeams(reviewerTeams ...string) PullRequestMergableOption
- func WithStates(states ...string) PullRequestMergableOption
- type PullRequestOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PullRequest ¶
type PullRequest struct {
// contains filtered or unexported fields
}
func NewPullRequestFromID ¶
func NewPullRequestFromID(ctx context.Context, client *ghapi.GithubClient, ghOrg, ghRepo string, ghPrId int, opts ...PullRequestOption) (*PullRequest, error)
NewPullRequestFromID fetches information about a pull request via GitHub as well as preparing the pull request as a series of patches that can be parsed internally.
func (*PullRequest) BaseBranch ¶
func (pr *PullRequest) BaseBranch() string
BaseBranch is the branch that the PR intends to merge into.
func (*PullRequest) LocalRepo ¶
func (pr *PullRequest) LocalRepo() string
LocalRepo is the path on disk to a copy of the pull request.
func (*PullRequest) Metadata ¶
func (pr *PullRequest) Metadata() *github.PullRequest
Metadata is auxiliary information related to the pull request, e.g. author, date, etc.
func (*PullRequest) Patches ¶
func (pr *PullRequest) Patches() []*patch.Patch
Patches contains the list of commits that this pull request consists of which are based on top of branch the pull request wishes to merge into.
func (*PullRequest) SatisfiesMergeRequirements ¶
func (pr *PullRequest) SatisfiesMergeRequirements(ctx context.Context, opts ...PullRequestMergableOption) (bool, map[string][]string, error)
SatisfiesMergeRequirements
func (*PullRequest) Workdir ¶
func (pr *PullRequest) Workdir() string
Workdir is the parent directory that the pull request has been cloned into and is a space where content can be temporarily stored.
type PullRequestMergableOption ¶
type PullRequestMergableOption func(*mergableOptions)
func WithApproveStates ¶
func WithApproveStates(approveStates ...string) PullRequestMergableOption
WithApproveStates sets the the state of the GitHub approval from the assignee.
func WithApproverComments ¶
func WithApproverComments(approverComments ...string) PullRequestMergableOption
WithApproverComments sets the regular expression that an approver writes.
func WithApproverTeams ¶
func WithApproverTeams(approverTeams ...string) PullRequestMergableOption
WithApproverTeams sets the the GitHub team that the approver must be a part of to be considered an approver.
func WithIgnoreLabels ¶
func WithIgnoreLabels(ignoreLabels ...string) PullRequestMergableOption
WithIgnoreLabels sets the ignore the PR if it has any of these labels.
func WithIgnoreStates ¶
func WithIgnoreStates(ignoreStates ...string) PullRequestMergableOption
WithIgnoreStates sets the ignore the PR if it has any of these states.
func WithLabels ¶
func WithLabels(labels ...string) PullRequestMergableOption
WithLabels sets the the PR must have these labels to be considered mergable.
func WithMinApprovals ¶
func WithMinApprovals(minApprovals int) PullRequestMergableOption
WithMinApprovals sets the minimum number of approvals required to be considered mergable
func WithMinReviews ¶
func WithMinReviews(minReviews int) PullRequestMergableOption
WithMinReviews sets the minimum number of reviews a PR requires to be considered mergable.
func WithNoConflicts ¶
func WithNoConflicts(noConflicts bool) PullRequestMergableOption
WithNoConflicts sets the pull request must not have any conflicts.
func WithNoDraft ¶
func WithNoDraft(noDraft bool) PullRequestMergableOption
WithNoDraft sets the pull request must not be in a draft state.
func WithNoRespectAssignees ¶
func WithNoRespectAssignees(noRespectAssignees bool) PullRequestMergableOption
WithNoRespectAssignees sets the whether the PR's assignees should be not considered approvers even if they are not part of a team/codeowner.
func WithNoRespectReviewers ¶
func WithNoRespectReviewers(noRespectReviewers bool) PullRequestMergableOption
WithNoRespectReviewers sets the whether the PR's requested reviewers review should not be considered even if they are not part of a team/codeowner.
func WithReviewStates ¶
func WithReviewStates(reviewStates ...string) PullRequestMergableOption
WithReviewStates sets the the state of the GitHub approval from the reivewer.
func WithReviewerComments ¶
func WithReviewerComments(reviewerComments ...string) PullRequestMergableOption
WithReviewerComments sets the regular expression that a reviewer writes.
func WithReviewerTeams ¶
func WithReviewerTeams(reviewerTeams ...string) PullRequestMergableOption
WithReviewerTeams sets the the GitHub team that the reviewer must be a part to be considered a reviewer.
func WithStates ¶
func WithStates(states ...string) PullRequestMergableOption
WithStates sets the consider the PR mergable if it has one of these supplied states.
type PullRequestOption ¶
type PullRequestOption func(*PullRequest) error
func WithBaseBranch ¶
func WithBaseBranch(name string) PullRequestOption
WithBaseBranch sets the branch that the pull request is intended to merge into.
func WithWorkdir ¶
func WithWorkdir(workdir string) PullRequestOption
WithWorkdir sets the base directory that can be used temporarily whilst manipulating the pull request.