githubclt

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package githubclt provides a github API client.

Index

Constants

View Source
const (
	StatusError   = "error"
	StatusFailure = "failure"
	StatusPending = "pending"
	StatusSuccess = "success"
)
View Source
const DefaultHTTPClientTimeout = time.Minute

Variables

View Source
var ErrPullRequestIsClosed = errors.New("pull request is closed")

Functions

This section is empty.

Types

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 New

func New(oauthAPItoken string) *Client

New returns a new github api client.

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 the most recent commit of baseBranch. If it is based on older commit, false is returned.

func (*Client) CombinedStatus

func (clt *Client) CombinedStatus(ctx context.Context, owner, repo, ref string) (string, time.Time, error)

CombinedStatus returns the combined check status and the last time the status changed for the ref.

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) PullRequestIsApproved added in v0.9.0

func (clt *Client) PullRequestIsApproved(ctx context.Context, owner, repo string, prNumber int) (bool, error)

PullRequestIsApproved returns true if the combined review status of a PR is approved.

func (*Client) UpdateBranch

func (clt *Client) UpdateBranch(ctx context.Context, owner, repo string, pullRequestNumber int) (bool, 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. If it's not uptodate and updating the PR was scheduled at github, true is returned. 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 PRIter

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

func (*PRIter) Next

func (it *PRIter) Next() (*github.PullRequest, error)

Next returns the next pullRequest. When the last result was returned a nil PullRequest is returned.

type PRIterator

type PRIterator interface {
	Next() (*github.PullRequest, error)
}

Jump to

Keyboard shortcuts

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