Documentation
¶
Index ¶
- Constants
- type Comment
- type Commit
- type Context
- type File
- type FileStatus
- type GitHubContext
- func (ghc *GitHubContext) Author() string
- func (ghc *GitHubContext) Branches() (base string, head string)
- func (ghc *GitHubContext) ChangedFiles() ([]*File, error)
- func (ghc *GitHubContext) Comments() ([]*Comment, error)
- func (ghc *GitHubContext) Commits() ([]*Commit, error)
- func (ghc *GitHubContext) CreatedAt() time.Time
- func (ghc *GitHubContext) HeadSHA() string
- func (ghc *GitHubContext) IsDraft() bool
- func (ghc *GitHubContext) Labels() ([]string, error)
- func (ghc *GitHubContext) LatestStatuses() (map[string]string, error)
- func (ghc *GitHubContext) Number() int
- func (ghc *GitHubContext) RepositoryCollaborators() (map[string]string, error)
- func (ghc *GitHubContext) RepositoryName() string
- func (ghc *GitHubContext) RepositoryOwner() string
- func (ghc *GitHubContext) RequestedReviewers() ([]*Reviewer, error)
- func (ghc *GitHubContext) Reviews() ([]*Review, error)
- func (ghc *GitHubContext) Teams() (map[string]string, error)
- func (ghc *GitHubContext) Title() string
- type GitHubMembershipContext
- func (mc *GitHubMembershipContext) IsCollaborator(org, repo, user, desiredPerm string) (bool, error)
- func (mc *GitHubMembershipContext) IsOrgMember(org, user string) (bool, error)
- func (mc *GitHubMembershipContext) IsTeamMember(team, user string) (bool, error)
- func (mc *GitHubMembershipContext) OrganizationMembers(org string) ([]string, error)
- func (mc *GitHubMembershipContext) TeamMembers(team string) ([]string, error)
- type Locator
- type MembershipContext
- type Review
- type ReviewState
- type Reviewer
- type ReviewerType
- type TemporaryError
Constants ¶
const ( // MaxPullRequestFiles is the max number of files returned by GitHub // https://developer.github.com/v3/pulls/#list-pull-requests-files MaxPullRequestFiles = 3000 // MaxPullRequestCommits is the max number of commits returned by GitHub // https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request MaxPullRequestCommits = 250 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commit ¶
type Commit struct {
SHA string
Parents []string
CommittedViaWeb bool
// Author is the login name of the author. It is empty if the author is not
// a real user.
Author string
// Commiter is the login name of the committer. It is empty if the
// committer is not a real user.
Committer string
// PushedAt is the timestamp when the commit was pushed. It is nil if that
// information is not available for this commit.
PushedAt *time.Time
}
type Context ¶
type Context interface {
MembershipContext
// RepositoryOwner returns the owner of the repo that the pull request targets.
RepositoryOwner() string
// RepositoryName returns the repo that the pull request targets.
RepositoryName() string
// Number returns the number of the pull request.
Number() int
// Title returns the title of the pull request
Title() string
// Author returns the username of the user who opened the pull request.
Author() string
// CreatedAt returns the time when the pull request was created.
CreatedAt() time.Time
// HeadSHA returns the SHA of the head commit of 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)
// ChangedFiles returns the files that were changed in this pull request.
ChangedFiles() ([]*File, error)
// Commits returns the commits that are part of this pull request. The
// commit order is implementation dependent.
Commits() ([]*Commit, error)
// Comments lists all comments on a Pull Request. The comment order is
// implementation dependent.
Comments() ([]*Comment, error)
// Reviews lists all reviews on a Pull Request. The review order is
// implementation dependent.
Reviews() ([]*Review, error)
// IsDraft returns the draft status of the Pull Request.
IsDraft() bool
// RepositoryCollaborators lists the set of collaborators, along with
// their respective permission on a repo.
RepositoryCollaborators() (map[string]string, error)
// Teams lists the set of team collaborators, along with
// their respective permission on a repo.
Teams() (map[string]string, error)
// RequestedReviewers returns any current and dismissed review requests on
// the pull request.
RequestedReviewers() ([]*Reviewer, error)
// LatestStatuses returns a map of status check names to the latest result
LatestStatuses() (map[string]string, error)
// Labels returns a list of labels applied on the Pull Request
Labels() ([]string, error)
}
Context is the context for a pull request. It defines methods to get information about the pull request and the VCS system containing the pull request (e.g. GitHub).
A new Context should be created for each request, so implementations are not required to be thread-safe.
func NewGitHubContext ¶
func NewGitHubContext(ctx context.Context, mbrCtx MembershipContext, client *github.Client, v4client *githubv4.Client, loc Locator) (Context, error)
NewGitHubContext creates a new pull.Context that makes GitHub requests to obtain information. It caches responses for the lifetime of the context. The pull request passed to the context must contain at least the base repository and the number or the function panics.
type FileStatus ¶
type FileStatus int
const ( FileModified FileStatus = iota FileAdded FileDeleted )
type GitHubContext ¶
type GitHubContext struct {
MembershipContext
// 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) Author ¶
func (ghc *GitHubContext) Author() string
func (*GitHubContext) Branches ¶
func (ghc *GitHubContext) Branches() (base string, head string)
Branches returns the names of the base and head branch. If the head branch is from another repository (it is a fork) then the branch name is `owner:branchName`.
func (*GitHubContext) ChangedFiles ¶
func (ghc *GitHubContext) ChangedFiles() ([]*File, error)
func (*GitHubContext) Comments ¶
func (ghc *GitHubContext) Comments() ([]*Comment, error)
func (*GitHubContext) Commits ¶
func (ghc *GitHubContext) Commits() ([]*Commit, error)
func (*GitHubContext) CreatedAt ¶ added in v1.20.0
func (ghc *GitHubContext) CreatedAt() time.Time
func (*GitHubContext) HeadSHA ¶
func (ghc *GitHubContext) HeadSHA() string
func (*GitHubContext) IsDraft ¶
func (ghc *GitHubContext) IsDraft() bool
func (*GitHubContext) Labels ¶
func (ghc *GitHubContext) Labels() ([]string, error)
func (*GitHubContext) LatestStatuses ¶
func (ghc *GitHubContext) LatestStatuses() (map[string]string, error)
func (*GitHubContext) Number ¶
func (ghc *GitHubContext) Number() int
func (*GitHubContext) RepositoryCollaborators ¶
func (ghc *GitHubContext) RepositoryCollaborators() (map[string]string, error)
func (*GitHubContext) RepositoryName ¶
func (ghc *GitHubContext) RepositoryName() string
func (*GitHubContext) RepositoryOwner ¶
func (ghc *GitHubContext) RepositoryOwner() string
func (*GitHubContext) RequestedReviewers ¶ added in v1.20.0
func (ghc *GitHubContext) RequestedReviewers() ([]*Reviewer, error)
func (*GitHubContext) Reviews ¶
func (ghc *GitHubContext) Reviews() ([]*Review, error)
func (*GitHubContext) Title ¶ added in v1.21.0
func (ghc *GitHubContext) Title() string
type GitHubMembershipContext ¶
type GitHubMembershipContext struct {
// contains filtered or unexported fields
}
func NewGitHubMembershipContext ¶
func NewGitHubMembershipContext(ctx context.Context, client *github.Client) *GitHubMembershipContext
func (*GitHubMembershipContext) IsCollaborator ¶
func (mc *GitHubMembershipContext) IsCollaborator(org, repo, user, desiredPerm string) (bool, error)
func (*GitHubMembershipContext) IsOrgMember ¶
func (mc *GitHubMembershipContext) IsOrgMember(org, user string) (bool, error)
func (*GitHubMembershipContext) IsTeamMember ¶
func (mc *GitHubMembershipContext) IsTeamMember(team, user string) (bool, error)
func (*GitHubMembershipContext) OrganizationMembers ¶
func (mc *GitHubMembershipContext) OrganizationMembers(org string) ([]string, error)
func (*GitHubMembershipContext) TeamMembers ¶
func (mc *GitHubMembershipContext) TeamMembers(team string) ([]string, error)
type Locator ¶
type Locator struct {
Owner string
Repo string
Number int
Value *github.PullRequest
}
Locator identifies a pull request and optionally contains a full or partial pull request object.
func (Locator) IsComplete ¶
IsComplete returns true if the locator contains a pull request object with all required fields.
type MembershipContext ¶
type MembershipContext interface {
// IsTeamMember returns true if the user is a member of the given team.
// Teams are specified as "org-name/team-name".
IsTeamMember(team, user string) (bool, error)
// IsOrgMember returns true if the user is a member of the given organzation.
IsOrgMember(org, user string) (bool, error)
// IsCollaborator returns true if the user meets the desiredPerm of the given organzation's repository.
IsCollaborator(org, repo, user, desiredPerm string) (bool, error)
// TeamMembers returns the list of usernames in the given organization's team.
TeamMembers(team string) ([]string, error)
// OrganizationMembers returns the list of org member usernames in the given organization.
OrganizationMembers(org string) ([]string, error)
}
MembershipContext defines methods to get information about about user membership in Github organizations and teams.
type ReviewState ¶
type ReviewState string
const ( ReviewApproved ReviewState = "approved" ReviewChangesRequested ReviewState = "changes_requested" ReviewCommented ReviewState = "commented" ReviewDismissed ReviewState = "dismissed" ReviewPending ReviewState = "pending" )
type Reviewer ¶ added in v1.20.0
type Reviewer struct {
Type ReviewerType
Name string
Removed bool
}
type ReviewerType ¶ added in v1.20.0
type ReviewerType string
const ( ReviewerUser ReviewerType = "user" ReviewerTeam ReviewerType = "team" )
type TemporaryError ¶ added in v1.21.2
type TemporaryError struct {
// contains filtered or unexported fields
}
func (*TemporaryError) Error ¶ added in v1.21.2
func (te *TemporaryError) Error() string