pull

package
v1.19.3 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllOpenPullRequestsForRef added in v1.19.2

func GetAllOpenPullRequestsForRef(ctx context.Context, client GitHubPullRequestClient, owner, repo, ref string) ([]*github.PullRequest, error)

GetAllOpenPullRequestsForRef returns all open pull requests for a given base branch reference.

func GetAllPossibleOpenPullRequestsForSHA added in v1.19.2

func GetAllPossibleOpenPullRequestsForSHA(ctx context.Context, client GitHubPullRequestClient, owner, repo, sha string) ([]*github.PullRequest, error)

GetAllPossibleOpenPullRequestsForSHA attempts to find all open pull requests associated with the given SHA using multiple methods in case we are dealing with a fork

func ListAllOpenPullRequestsFilteredBySHA added in v1.19.2

func ListAllOpenPullRequestsFilteredBySHA(ctx context.Context, client GitHubPullRequestClient, owner, repo, sha string) ([]*github.PullRequest, error)

ListAllOpenPullRequestsFilteredBySHA returns all open pull requests where the HEAD of the source branch matches the given SHA by fetching all open PRs and filtering.

Types

type Commit

type Commit struct {
	SHA     string
	Message string
}

type Context

type Context interface {
	// Owner returns the pull request repository owner.
	Owner() string

	// Repo returns the pull request repository name.
	Repo() string

	// Number returns the pull request number.
	Number() int

	// Locator returns a locator string for the pull request. The locator
	// string is formatted as "<owner>/<repository>#<number>"
	Locator() string

	// Title returns the pull request title.
	Title() string

	// Body returns the pull request body.
	Body() string

	// HeadSHA returns the SHA hash of the latest commit in the pull request.
	HeadSHA() string

	// Branches returns the base (also known as target) and head branch names
	// of this pull request. Branches in this repository have no prefix, while
	// branches in forks are prefixed with the owner of the fork and a colon.
	// The base branch will always be unprefixed.
	Branches() (base string, head string)

	// MergeState returns the current mergability of the pull request. It
	// always returns the most up-to-date state possible.
	MergeState(ctx context.Context) (*MergeState, error)

	// RequiredStatuses returns the names of the required status
	// checks for the pull request.
	RequiredStatuses(ctx context.Context) ([]string, error)

	// PushRestrictions returns true if the target barnch of the pull request
	// restricts the users or teams that have push access.
	PushRestrictions(ctx context.Context) (bool, error)

	// CurrentSuccessStatuses returns the names of all currently
	// successful status checks for the pull request.
	CurrentSuccessStatuses(ctx context.Context) ([]string, error)

	// Comments lists all comments on the pull request.
	Comments(ctx context.Context) ([]string, error)

	// Commits lists all commits on the pull request.
	Commits(ctx context.Context) ([]*Commit, error)

	// Labels lists all labels on the pull request.
	Labels(ctx context.Context) ([]string, error)

	// IsTargeted returns true if the head branch of this pull request is the
	// target branch of other open PRs on the repository.
	IsTargeted(ctx context.Context) (bool, error)

	// IsDraft returns true if the PR is in a draft state.
	IsDraft(ctx context.Context) bool

	// AutoMerge returns true if the PR is configured to be automatically merged.
	AutoMerge(ctx context.Context) bool
}

Context is the context for a pull request. It defines methods to get information about the pull request. It is assumed that the implementation is not thread safe.

A new Context should be created each time a Pull Request is being evaluated such that implementations are not required to consider cache invalidation.

func NewGithubContext

func NewGithubContext(client *github.Client, pr *github.PullRequest) Context

type GitHubPullRequestClient added in v1.19.2

type GitHubPullRequestClient interface {
	ListPullRequestsWithCommit(ctx context.Context, owner, repo, sha string, opts *github.ListOptions) ([]*github.PullRequest, *github.Response, error)
	List(ctx context.Context, owner, repo string, opts *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error)
}

GitHubPullRequestClient is an interface that wraps the methods used from the github.Client.

type GithubContext

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

GithubContext is a Context implementation that gets information from GitHub. A new instance must be created for each request.

func (*GithubContext) AutoMerge added in v1.16.0

func (ghc *GithubContext) AutoMerge(ctx context.Context) bool

func (*GithubContext) Body

func (ghc *GithubContext) Body() string

func (*GithubContext) Branches

func (ghc *GithubContext) Branches() (base string, head string)

func (*GithubContext) Comments

func (ghc *GithubContext) Comments(ctx context.Context) ([]string, error)

func (*GithubContext) Commits

func (ghc *GithubContext) Commits(ctx context.Context) ([]*Commit, error)

func (*GithubContext) CurrentSuccessStatuses

func (ghc *GithubContext) CurrentSuccessStatuses(ctx context.Context) ([]string, error)

func (*GithubContext) HeadSHA

func (ghc *GithubContext) HeadSHA() string

func (*GithubContext) IsDraft added in v1.14.0

func (ghc *GithubContext) IsDraft(ctx context.Context) bool

func (*GithubContext) IsTargeted

func (ghc *GithubContext) IsTargeted(ctx context.Context) (bool, error)

func (*GithubContext) Labels

func (ghc *GithubContext) Labels(ctx context.Context) ([]string, error)

func (*GithubContext) Locator

func (ghc *GithubContext) Locator() string

func (*GithubContext) MergeState

func (ghc *GithubContext) MergeState(ctx context.Context) (*MergeState, error)

func (*GithubContext) Number

func (ghc *GithubContext) Number() int

func (*GithubContext) Owner

func (ghc *GithubContext) Owner() string

func (*GithubContext) PushRestrictions

func (ghc *GithubContext) PushRestrictions(ctx context.Context) (bool, error)

func (*GithubContext) Repo

func (ghc *GithubContext) Repo() string

func (*GithubContext) RequiredStatuses

func (ghc *GithubContext) RequiredStatuses(ctx context.Context) ([]string, error)

func (*GithubContext) Title

func (ghc *GithubContext) Title() string

type MergeState

type MergeState struct {
	Closed    bool
	Mergeable *bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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