Documentation
¶
Index ¶
- Variables
- func CheckoutBranch(log *logrus.Entry, repo *git.Repository, branchName string) error
- func CloneRepository(log *logrus.Entry, url string, token string, path string, ...) (*git.Repository, string, error)
- func GetPullRequestBaseOwnerName(pullRequest *github.PullRequest) string
- func GetPullRequestBaseRepoName(pullRequest *github.PullRequest) string
- func GetPullRequestHeadOwnerName(pullRequest *github.PullRequest) string
- func GetPullRequestHeadRepoName(pullRequest *github.PullRequest) string
- func GetPullRequestNumber(pullRequest *github.PullRequest) int
- func PaginatedRequest(initFn func() interface{}, ...) (interface{}, error)
- func ParseNumPages(resp *github.Response) int
- func ParseNumPagesFromLink(link string) int
- func Push(log *logrus.Entry, repo *git.Repository, remoteName string, branchName string, ...) error
- func RebaseOnto(log *logrus.Entry, repo *git.Repository, branchName string, ...) error
- type AddProjectV2ItemByIdInput
- type CommitStatus
- type CreateCommitStatusOptions
- type FieldDetails
- type FieldNode
- type FieldValue
- type Fields
- type FirstCommitAndReviewDateQuery
- type GQLProjectV2Item
- type GQLReviewThread
- type GetApprovalsCountQuery
- type GetLastCommitSHAQuery
- type GetObjectQuery
- type GithubAppClient
- type GithubClient
- func (c *GithubClient) AddAssignees(ctx context.Context, owner string, repo string, number int, assignees []string) (*github.Issue, *github.Response, error)
- func (c *GithubClient) AddLabels(ctx context.Context, owner string, repo string, number int, labels []string) ([]*github.Label, *github.Response, error)
- func (c *GithubClient) CreateComment(ctx context.Context, owner string, repo string, number int, ...) (*github.IssueComment, *github.Response, error)
- func (c *GithubClient) CreateCommitStatus(ctx context.Context, owner string, repo string, headSHA string, ...) (*CommitStatus, error)
- func (c *GithubClient) CreateLabel(ctx context.Context, owner string, repo string, label *github.Label) (*github.Label, *github.Response, error)
- func (c *GithubClient) DeleteComment(ctx context.Context, owner string, repo string, commentId int64) (*github.Response, error)
- func (c *GithubClient) DeleteReference(ctx context.Context, owner, repo, ref string) error
- func (c *GithubClient) DownloadContents(ctx context.Context, filePath string, branch *github.PullRequestBranch) ([]byte, error)
- func (c *GithubClient) EditComment(ctx context.Context, owner string, repo string, commentId int64, ...) (*github.IssueComment, *github.Response, error)
- func (c *GithubClient) EditIssue(ctx context.Context, owner string, repo string, number int, ...) (*github.Issue, *github.Response, error)
- func (c *GithubClient) EditLabel(ctx context.Context, owner string, repo string, name string, ...) (*github.Label, *github.Response, error)
- func (c *GithubClient) EditPullRequest(ctx context.Context, owner string, repo string, number int, ...) (*github.PullRequest, *github.Response, error)
- func (c *GithubClient) GetApprovalsCount(ctx context.Context, owner, repo string, number int) (int, error)
- func (c *GithubClient) GetCheckRunsForRef(ctx context.Context, owner string, repo string, number int, ref string, ...) ([]*github.CheckRun, error)
- func (c *GithubClient) GetClientGraphQL() *githubv4.Client
- func (c *GithubClient) GetClientREST() *github.Client
- func (c *GithubClient) GetComments(ctx context.Context, owner string, repo string, number int, ...) ([]*github.IssueComment, error)
- func (c *GithubClient) GetDefaultRepositoryBranch(ctx context.Context, owner string, repo string) (string, error)
- func (c *GithubClient) GetFirstCommitAndReviewDate(ctx context.Context, owner, repo string, number int) (*time.Time, *time.Time, error)
- func (c *GithubClient) GetIssue(ctx context.Context, owner, repo string, number int) (*github.Issue, *github.Response, error)
- func (c *GithubClient) GetIssueTimeline(ctx context.Context, owner string, repo string, number int) ([]*github.Timeline, error)
- func (c *GithubClient) GetIssuesAvailableAssignees(ctx context.Context, owner string, repo string) ([]*github.User, error)
- func (c *GithubClient) GetLabel(ctx context.Context, owner string, repo string, name string) (*github.Label, *github.Response, error)
- func (c *GithubClient) GetLastCommitSHA(ctx context.Context, owner, repo string, number int) (string, error)
- func (c *GithubClient) GetLinkedProjectsForIssue(ctx context.Context, owner, repo string, number int, retryCount int) ([]GQLProjectV2Item, error)
- func (c *GithubClient) GetLinkedProjectsForPullRequest(ctx context.Context, owner, repo string, number int, retryCount int) ([]GQLProjectV2Item, error)
- func (c *GithubClient) GetProjectFieldsByProjectNumber(ctx context.Context, owner, repo string, projectNumber uint64, retryCount int) ([]FieldNode, error)
- func (c *GithubClient) GetProjectV2ByName(ctx context.Context, owner, repo, name string) (*ProjectV2, error)
- func (c *GithubClient) GetPullRequest(ctx context.Context, owner string, repo string, number int) (*github.PullRequest, *github.Response, error)
- func (c *GithubClient) GetPullRequestClosingIssuesCount(ctx context.Context, owner string, repo string, number int) (int, error)
- func (c *GithubClient) GetPullRequestCommits(ctx context.Context, owner string, repo string, number int) ([]*github.RepositoryCommit, error)
- func (c *GithubClient) GetPullRequestFiles(ctx context.Context, owner string, repo string, number int) ([]*github.CommitFile, error)
- func (c *GithubClient) GetPullRequestLastPushDate(ctx context.Context, owner string, repo string, number int) (time.Time, error)
- func (c *GithubClient) GetPullRequestReviewers(ctx context.Context, owner string, repo string, number int, ...) (*github.Reviewers, error)
- func (c *GithubClient) GetPullRequestReviews(ctx context.Context, owner string, repo string, number int) ([]*github.PullRequestReview, error)
- func (c *GithubClient) GetPullRequests(ctx context.Context, owner string, repo string) ([]*github.PullRequest, error)
- func (c *GithubClient) GetRepoCollaborators(ctx context.Context, owner string, repo string) ([]*github.User, error)
- func (c *GithubClient) GetRepositoryBranch(ctx context.Context, owner string, repo string, branch string, ...) (*github.Branch, *github.Response, error)
- func (c *GithubClient) GetReviewThreads(ctx context.Context, owner string, repo string, number int, retryCount int) ([]GQLReviewThread, error)
- func (c *GithubClient) GetToken() string
- func (c *GithubClient) IsFileBinary(ctx context.Context, owner, repo, branch, file string) (bool, error)
- func (c *GithubClient) ListCheckRunsForRef(ctx context.Context, owner string, repo string, ref string, ...) (*github.ListCheckRunsResults, *github.Response, error)
- func (c *GithubClient) ListIssuesByRepo(ctx context.Context, owner string, repo string, ...) ([]*github.Issue, *github.Response, error)
- func (c *GithubClient) ListOrganizationMembers(ctx context.Context, org string, opts *github.ListMembersOptions) ([]*github.User, *github.Response, error)
- func (c *GithubClient) ListTeamMembersBySlug(ctx context.Context, org string, slug string, ...) ([]*github.User, *github.Response, error)
- func (c *GithubClient) Merge(ctx context.Context, owner string, repo string, number int, ...) (*github.PullRequestMergeResult, *github.Response, error)
- func (c *GithubClient) RemoveLabelForIssue(ctx context.Context, owner string, repo string, number int, label string) (*github.Response, error)
- func (c *GithubClient) RequestReviewers(ctx context.Context, owner string, repo string, number int, ...) (*github.PullRequest, *github.Response, error)
- func (c *GithubClient) Review(ctx context.Context, owner string, repo string, number int, ...) (*github.PullRequestReview, *github.Response, error)
- func (c *GithubClient) TriggerWorkflowByFileName(ctx context.Context, owner, repo, branch, workflowFileName string) (*github.Response, error)
- type IssueLinkedProjectsQuery
- type LastPushQuery
- type NumberFieldValue
- type PageInfo
- type ProjectV2
- type PullRequestLinkedProjectsQuery
- type ReviewThreadsQuery
- type SingleSelectFieldDetails
- type SingleSelectFieldValue
- type TextFieldValue
- type UpdateProjectV2ItemFieldValueInput
Constants ¶
This section is empty.
Variables ¶
var ( ErrProjectHasNoStatusField = errors.New("project has no status field") ErrProjectHasNoSuchField = errors.New("project field not found") ErrProjectHasNoSuchFieldValue = errors.New("project field value not found") ErrProjectItemsNotFound = errors.New("project items not found") ErrProjectNotFound = errors.New("project not found") ErrProjectStatusNotFound = errors.New("project status not found") )
Functions ¶
func CheckoutBranch ¶ added in v3.5.0
CheckoutBranch checks out a given branch in the given repository.
func CloneRepository ¶ added in v3.5.0
func CloneRepository(log *logrus.Entry, url string, token string, path string, options *git.CloneOptions) (*git.Repository, string, error)
CloneRepository clones a repository from a given URL to the provided path. url needs to be an HTTPS uri (e.g. https://github.com/libgit2/TestGitRepository) path can be empty. In this case, the repository will be cloned to a temporary location and the location is returned.
func GetPullRequestBaseOwnerName ¶
func GetPullRequestBaseOwnerName(pullRequest *github.PullRequest) string
func GetPullRequestBaseRepoName ¶
func GetPullRequestBaseRepoName(pullRequest *github.PullRequest) string
func GetPullRequestHeadOwnerName ¶
func GetPullRequestHeadOwnerName(pullRequest *github.PullRequest) string
func GetPullRequestHeadRepoName ¶
func GetPullRequestHeadRepoName(pullRequest *github.PullRequest) string
func GetPullRequestNumber ¶
func GetPullRequestNumber(pullRequest *github.PullRequest) int
func PaginatedRequest ¶
func ParseNumPages ¶
ParseNumPages Given a link header string representing pagination info, returns total number of pages.
func ParseNumPagesFromLink ¶
func Push ¶ added in v3.5.0
func Push(log *logrus.Entry, repo *git.Repository, remoteName string, branchName string, token string, force bool) error
Push performs a push of the provided remote/branch.
func RebaseOnto ¶ added in v3.5.0
func RebaseOnto(log *logrus.Entry, repo *git.Repository, branchName string, rebaseOptions *git.RebaseOptions) error
RebaseOnto performs a rebase of the current repository Head onto the given branch. Inspired by https://github.com/libgit2/git2go/blob/main/rebase_test.go#L359
Types ¶
type AddProjectV2ItemByIdInput ¶ added in v3.19.0
type CommitStatus ¶ added in v3.24.0
type CreateCommitStatusOptions ¶ added in v3.24.0
type FieldDetails ¶
type FieldNode ¶
type FieldNode struct {
TypeName string `graphql:"__typename"`
SingleSelectFieldDetails SingleSelectFieldDetails `graphql:"... on ProjectV2SingleSelectField"`
FieldDetails FieldDetails `graphql:"... on ProjectV2Field"`
}
type FieldValue ¶ added in v3.19.0
type FieldValue interface{}
type FirstCommitAndReviewDateQuery ¶ added in v3.13.0
type FirstCommitAndReviewDateQuery struct {
Repository struct {
PullRequest struct {
Commits struct {
Nodes []struct {
Commit struct {
AuthoredDate time.Time
}
}
} `graphql:"commits(first: 1)"`
Reviews struct {
Nodes []struct {
CreatedAt time.Time
}
} `graphql:"reviews(first: 1)"`
} `graphql:"pullRequest(number: $pullRequestNumber)"`
} `graphql:"repository(owner: $repositoryOwner, name: $repositoryName)"`
}
type GQLProjectV2Item ¶ added in v3.16.0
type GQLReviewThread ¶
type GetApprovalsCountQuery ¶ added in v3.18.0
type GetApprovalsCountQuery struct {
Repository struct {
PullRequest struct {
Reviews struct {
TotalCount int `graphql:"totalCount"`
} `graphql:"reviews(first: 1, states: [APPROVED])"`
} `graphql:"pullRequest(number: $pullRequestNumber)"`
} `graphql:"repository(owner: $repositoryOwner, name: $repositoryName)"`
}
type GetLastCommitSHAQuery ¶ added in v3.16.0
type GetLastCommitSHAQuery struct {
Repository struct {
PullRequest struct {
Commits struct {
Nodes []struct {
Commit struct {
OID string
}
}
} `graphql:"commits(last: 1)"`
} `graphql:"pullRequest(number: $pullRequestNumber)"`
} `graphql:"repository(owner: $repositoryOwner, name: $repositoryName)"`
}
type GetObjectQuery ¶ added in v3.16.0
type GetObjectQuery struct {
Repository struct {
Object struct {
Blog struct {
IsBinary bool
} `graphql:"... on Blob"`
} `graphql:"object(expression: $expression)"`
} `graphql:"repository(owner: $repositoryOwner, name: $repositoryName)"`
}
type GithubAppClient ¶ added in v3.19.0
func NewGithubAppClient ¶ added in v3.19.0
func NewGithubAppClient(gitHubAppID int64, gitHubAppPrivateKey []byte) (*GithubAppClient, error)
func (*GithubAppClient) CreateInstallationToken ¶ added in v3.19.0
func (c *GithubAppClient) CreateInstallationToken(ctx context.Context, id int64, opts *github.InstallationTokenOptions) (*github.InstallationToken, error)
CreateInstallationToken creates a new installation token for the github app. For more details see https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app
func (*GithubAppClient) GetInstallations ¶ added in v3.19.0
func (c *GithubAppClient) GetInstallations(ctx context.Context) ([]*github.Installation, error)
GetInstallations returns all installations for the github app. For more details see https://docs.github.com/en/rest/apps/apps#list-installations-for-the-authenticated-app
type GithubClient ¶
type GithubClient struct {
// contains filtered or unexported fields
}
func NewGithubClient ¶
func NewGithubClient(clientREST *github.Client, clientGQL *githubv4.Client) *GithubClient
func NewGithubClientFromToken ¶
func NewGithubClientFromToken(ctx context.Context, token string) *GithubClient
func (*GithubClient) AddAssignees ¶
func (*GithubClient) CreateComment ¶
func (c *GithubClient) CreateComment(ctx context.Context, owner string, repo string, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error)
func (*GithubClient) CreateCommitStatus ¶ added in v3.24.0
func (c *GithubClient) CreateCommitStatus(ctx context.Context, owner string, repo string, headSHA string, opt *CreateCommitStatusOptions) (*CommitStatus, error)
func (*GithubClient) CreateLabel ¶
func (*GithubClient) DeleteComment ¶
func (*GithubClient) DeleteReference ¶ added in v3.11.0
func (c *GithubClient) DeleteReference(ctx context.Context, owner, repo, ref string) error
func (*GithubClient) DownloadContents ¶
func (c *GithubClient) DownloadContents(ctx context.Context, filePath string, branch *github.PullRequestBranch) ([]byte, error)
func (*GithubClient) EditComment ¶
func (c *GithubClient) EditComment(ctx context.Context, owner string, repo string, commentId int64, comment *github.IssueComment) (*github.IssueComment, *github.Response, error)
func (*GithubClient) EditPullRequest ¶
func (c *GithubClient) EditPullRequest(ctx context.Context, owner string, repo string, number int, pull *github.PullRequest) (*github.PullRequest, *github.Response, error)
func (*GithubClient) GetApprovalsCount ¶ added in v3.18.0
func (*GithubClient) GetCheckRunsForRef ¶ added in v3.15.0
func (*GithubClient) GetClientGraphQL ¶
func (c *GithubClient) GetClientGraphQL() *githubv4.Client
func (*GithubClient) GetClientREST ¶
func (c *GithubClient) GetClientREST() *github.Client
FIXME: Remove these to hide the implementation details.
func (*GithubClient) GetComments ¶ added in v3.3.0
func (c *GithubClient) GetComments(ctx context.Context, owner string, repo string, number int, opts *github.IssueListCommentsOptions) ([]*github.IssueComment, error)
func (*GithubClient) GetDefaultRepositoryBranch ¶ added in v3.3.0
func (*GithubClient) GetFirstCommitAndReviewDate ¶ added in v3.13.0
func (*GithubClient) GetIssueTimeline ¶ added in v3.3.0
func (*GithubClient) GetIssuesAvailableAssignees ¶
func (*GithubClient) GetLastCommitSHA ¶ added in v3.16.0
func (*GithubClient) GetLinkedProjectsForIssue ¶ added in v3.16.1
func (c *GithubClient) GetLinkedProjectsForIssue(ctx context.Context, owner, repo string, number int, retryCount int) ([]GQLProjectV2Item, error)
func (*GithubClient) GetLinkedProjectsForPullRequest ¶ added in v3.16.1
func (c *GithubClient) GetLinkedProjectsForPullRequest(ctx context.Context, owner, repo string, number int, retryCount int) ([]GQLProjectV2Item, error)
func (*GithubClient) GetProjectFieldsByProjectNumber ¶
func (*GithubClient) GetProjectV2ByName ¶
func (*GithubClient) GetPullRequest ¶
func (*GithubClient) GetPullRequestClosingIssuesCount ¶ added in v3.3.0
func (*GithubClient) GetPullRequestCommits ¶
func (c *GithubClient) GetPullRequestCommits(ctx context.Context, owner string, repo string, number int) ([]*github.RepositoryCommit, error)
func (*GithubClient) GetPullRequestFiles ¶
func (c *GithubClient) GetPullRequestFiles(ctx context.Context, owner string, repo string, number int) ([]*github.CommitFile, error)
func (*GithubClient) GetPullRequestLastPushDate ¶ added in v3.5.0
func (*GithubClient) GetPullRequestReviewers ¶
func (*GithubClient) GetPullRequestReviews ¶
func (c *GithubClient) GetPullRequestReviews(ctx context.Context, owner string, repo string, number int) ([]*github.PullRequestReview, error)
func (*GithubClient) GetPullRequests ¶
func (c *GithubClient) GetPullRequests(ctx context.Context, owner string, repo string) ([]*github.PullRequest, error)
func (*GithubClient) GetRepoCollaborators ¶
func (*GithubClient) GetRepositoryBranch ¶
func (*GithubClient) GetReviewThreads ¶
func (c *GithubClient) GetReviewThreads(ctx context.Context, owner string, repo string, number int, retryCount int) ([]GQLReviewThread, error)
func (*GithubClient) GetToken ¶ added in v3.23.0
func (c *GithubClient) GetToken() string
func (*GithubClient) IsFileBinary ¶ added in v3.16.0
func (*GithubClient) ListCheckRunsForRef ¶
func (c *GithubClient) ListCheckRunsForRef(ctx context.Context, owner string, repo string, ref string, opts *github.ListCheckRunsOptions) (*github.ListCheckRunsResults, *github.Response, error)
func (*GithubClient) ListIssuesByRepo ¶
func (*GithubClient) ListOrganizationMembers ¶
func (*GithubClient) ListTeamMembersBySlug ¶
func (*GithubClient) Merge ¶
func (c *GithubClient) Merge(ctx context.Context, owner string, repo string, number int, commitMessage string, options *github.PullRequestOptions) (*github.PullRequestMergeResult, *github.Response, error)
func (*GithubClient) RemoveLabelForIssue ¶
func (*GithubClient) RequestReviewers ¶
func (c *GithubClient) RequestReviewers(ctx context.Context, owner string, repo string, number int, reviewers github.ReviewersRequest) (*github.PullRequest, *github.Response, error)
func (*GithubClient) Review ¶ added in v3.10.0
func (c *GithubClient) Review(ctx context.Context, owner string, repo string, number int, review *github.PullRequestReviewRequest) (*github.PullRequestReview, *github.Response, error)
func (*GithubClient) TriggerWorkflowByFileName ¶ added in v3.18.0
type IssueLinkedProjectsQuery ¶ added in v3.16.1
type IssueLinkedProjectsQuery struct {
Repository struct {
Issue struct {
ProjectItems *struct {
Nodes []GQLProjectV2Item
PageInfo struct {
EndCursor githubv4.String
HasNextPage bool
}
} `graphql:"projectItems(first: 10, after: $projectItemsCursor)"`
} `graphql:"issue(number: $issueNumber)"`
} `graphql:"repository(owner: $repositoryOwner, name: $repositoryName)"`
}
type LastPushQuery ¶ added in v3.5.0
type LastPushQuery struct {
Repository struct {
PullRequest struct {
TimelineItems struct {
Nodes []struct {
Typename string `graphql:"__typename"`
HeadRefForcePushedEvent struct {
CreatedAt *time.Time
} `graphql:"... on HeadRefForcePushedEvent"`
PullRequestCommit struct {
Commit struct {
PushedDate *time.Time
CommittedDate *time.Time
}
} `graphql:"... on PullRequestCommit"`
}
} `graphql:"timelineItems(last: 1, itemTypes: [HEAD_REF_FORCE_PUSHED_EVENT, PULL_REQUEST_COMMIT])"`
} `graphql:"pullRequest(number: $pullRequestNumber)"`
} `graphql:"repository(owner: $repositoryOwner, name: $repositoryName)"`
}
type NumberFieldValue ¶ added in v3.19.0
type PullRequestLinkedProjectsQuery ¶ added in v3.16.1
type PullRequestLinkedProjectsQuery struct {
Repository struct {
PullRequest struct {
ProjectItems *struct {
Nodes []GQLProjectV2Item
PageInfo struct {
EndCursor githubv4.String
HasNextPage bool
}
} `graphql:"projectItems(first: 10, after: $projectItemsCursor)"`
} `graphql:"pullRequest(number: $issueNumber)"`
} `graphql:"repository(owner: $repositoryOwner, name: $repositoryName)"`
}
type ReviewThreadsQuery ¶
type ReviewThreadsQuery struct {
Repository struct {
PullRequest struct {
ReviewThreads struct {
Nodes []GQLReviewThread
PageInfo struct {
EndCursor githubv4.String
HasNextPage bool
}
} `graphql:"reviewThreads(first: 10, after: $reviewThreadsCursor)"`
} `graphql:"pullRequest(number: $pullRequestNumber)"`
} `graphql:"repository(owner: $repositoryOwner, name: $repositoryName)"`
}
type SingleSelectFieldDetails ¶ added in v3.19.0
type SingleSelectFieldValue ¶ added in v3.19.0
type SingleSelectFieldValue struct {
SingleSelectOptionId string `json:"singleSelectOptionId"`
}
type TextFieldValue ¶ added in v3.19.0
type TextFieldValue struct {
Text string `json:"text"`
}
type UpdateProjectV2ItemFieldValueInput ¶ added in v3.19.0
type UpdateProjectV2ItemFieldValueInput struct {
ItemID string `json:"itemId"`
Value FieldValue `json:"value"`
ProjectID string `json:"projectId"`
FieldID string `json:"fieldId"`
}