Documentation
¶
Overview ¶
Package githubclt provides a github API client.
Index ¶
- Constants
- Variables
- type CIJobStatus
- type CIStatus
- type Client
- func (clt *Client) AddLabel(ctx context.Context, owner, repo string, pullRequestOrIssueNumber int, ...) error
- func (clt *Client) BranchIsBehindBase(ctx context.Context, owner, repo, baseBranch, branch string) (behind bool, err error)
- func (clt *Client) CreateIssueComment(ctx context.Context, owner, repo string, issueOrPRNr int, comment string) error
- func (clt *Client) ListPullRequests(ctx context.Context, owner, repo, state, sort, sortDirection string) PRIterator
- func (clt *Client) PRIsUptodate(ctx context.Context, owner, repo string, pullRequestNumber int) (isUptodate bool, headSHA string, err error)
- func (clt *Client) ReadyForMerge(ctx context.Context, owner, repo string, prNumber int) (*ReadyForMergeStatus, error)
- func (clt *Client) RemoveLabel(ctx context.Context, owner, repo string, pullRequestOrIssueNumber int, ...) error
- func (clt *Client) UpdateBranch(ctx context.Context, owner, repo string, pullRequestNumber int) (changed, scheduled bool, err error)
- type PRIter
- type PRIterator
- type ReadyForMergeStatus
- type ReviewDecision
Constants ¶
const ( ReviewDecisionApproved = ReviewDecision(githubv4.PullRequestReviewDecisionApproved) ReviewDecisionChangesRequested = ReviewDecision(githubv4.PullRequestReviewDecisionChangesRequested) ReviewDecisionReviewRequired = ReviewDecision(githubv4.PullRequestReviewDecisionReviewRequired) )
const DefaultHTTPClientTimeout = time.Minute
Variables ¶
var ErrPullRequestIsClosed = errors.New("pull request is closed")
Functions ¶
This section is empty.
Types ¶
type CIJobStatus ¶ added in v0.12.0
CIJobStatus is the status of a CI job. It represents the status of GitHub CheckRuns and Commit statuses.
type CIStatus ¶ added in v0.12.0
type CIStatus string
CIStatus abstracts the multiple result values of GitHub check runs and Commit statuses into a single value.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an github API client. All methods return a goorderr.RetryableError when an operation can be retried. This can be e.g. the case when the API ratelimit is exceeded.
func (*Client) AddLabel ¶ added in v0.13.0
func (clt *Client) AddLabel(ctx context.Context, owner, repo string, pullRequestOrIssueNumber int, label string) error
AddLabel adds a label to Pull-Request or Issue.
func (*Client) BranchIsBehindBase ¶ added in v0.8.2
func (clt *Client) BranchIsBehindBase(ctx context.Context, owner, repo, baseBranch, branch string) (behind bool, err error)
BranchIsBehindBase returns true if branch is based on an old commit of baseBranch. If it is based on older commit, false is returned.
func (*Client) CreateIssueComment ¶
func (clt *Client) CreateIssueComment(ctx context.Context, owner, repo string, issueOrPRNr int, comment string) error
CreateIssueComment creates a comment in a issue or pull request
func (*Client) ListPullRequests ¶
func (clt *Client) ListPullRequests(ctx context.Context, owner, repo, state, sort, sortDirection string) PRIterator
ListPullRequests returns an iterator for receiving all pull requests. The parameters state, sort, sortDirection expect the same values then their pendants in the struct github.PullRequestListOptions. all pull requests should be returned.
func (*Client) PRIsUptodate ¶
func (clt *Client) PRIsUptodate(ctx context.Context, owner, repo string, pullRequestNumber int) (isUptodate bool, headSHA string, err error)
PullRequestIsUptodateWithBase returns true if the pull request is open and contains all changes from it's base branch. Additionally it returns the SHA of the head commit for which the status was checked. If the PR is closed PullRequestIsClosedError is returned.
func (*Client) ReadyForMerge ¶ added in v0.12.0
func (clt *Client) ReadyForMerge(ctx context.Context, owner, repo string, prNumber int) (*ReadyForMergeStatus, error)
ReadyForMerge returns the ReviewDecision and the overall CI status. The CiStatus is calculated based on the CheckRun results, commit Status of the HEAD commit of the PR and the configured required status check contexts of the base branch. CiStatus is pending, if one or more required or non required checks are in a pending state. CiStatus is successful, if no CI status is in pending state and required checks succeeded. Failed status of non-required checks are treated as successful. The following CheckRun results are interpreted as Pending: - status: IN_PROGRESS - status: PENDING - status: QUEUED - status: WAITING - status: COMPLETED, conclusion: ACTION_REQUIRED The following results with a COMPLETED status are treated as failure: - CANCELLED - FAILURE - STALE - STARTUP_FAILURE - TIMED_OUT The following results with a COMPLETED status are treated as successful: - SKIPPED - NEUTRAL - SUCCESS
func (*Client) RemoveLabel ¶ added in v0.11.0
func (clt *Client) RemoveLabel(ctx context.Context, owner, repo string, pullRequestOrIssueNumber int, label string) error
RemoveLabel removes a label from a Pull-Request or issue. If the issue or PR does not have the label, the operation succeeds.
func (*Client) UpdateBranch ¶
func (clt *Client) UpdateBranch(ctx context.Context, owner, repo string, pullRequestNumber int) (changed, scheduled bool, err error)
UpdateBranch schedules merging the base-branch into a pull request branch. If the PR contains all changes of it's base branch, false is returned for changed If it's not uptodate and updating the PR was scheduled at github, true is returned for changed and scheduled. If the PR was updated while the method was executed, a goorderr.RetryableError is returned and the operation can be retried. If the branch can not be updated automatically because of a merge conflict, an error is returned.
type PRIterator ¶
type PRIterator interface {
Next() (*github.PullRequest, error)
}
type ReadyForMergeStatus ¶ added in v0.12.0
type ReadyForMergeStatus struct {
ReviewDecision ReviewDecision
CIStatus CIStatus
Statuses []*CIJobStatus
}
ReadyForMergeStatus represent the information deciding if a pull request is ready to be merged. It contains the review decision and CI job results.
type ReviewDecision ¶ added in v0.12.0
type ReviewDecision string
ReviewDecision is the result of a pull request review.