github

package
v0.0.0-...-61a96ab Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// PullRequestFiles returns a list of files used in a particular pull request.
	PullRequestFiles(ctx context.Context, number int) (created, removed, modified []string, err error)

	// CreatePullRequest creates a new pull request.
	CreatePullRequest(ctx context.Context, title, head, base, body string) (string, int, error)

	// ClosePullRequests closes pull requests.
	ClosePullRequests(prs []int, removeRemoteBranch bool) error

	// FindPullRequests searches pull requests with an owner and title.
	FindPullRequests(ctx context.Context, owner, titleMatch string) (prs []*PullRequest, err error)

	// RequestReviewers assigns the reviewers to a pull request.
	RequestReviewers(pr int, names []string) error

	// RemoveRemoveRef removes a reference from remote git repository.
	RemoveRemoveRef(ctx context.Context, ref string) error

	// CreatePullRequestComment creates a new comment on a pull request.
	CreatePullRequestComment(ctx context.Context, id int, text string) error
}

Client is a github interface to interact with pull requests.

func NewGithub

func NewGithub(opts ...Option) (Client, error)

NewGithub returns a new instance fo github object.

type Github

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

Github is an abstraction over github API.

func (*Github) ClosePullRequests

func (gh *Github) ClosePullRequests(prs []int, removeRemoteBranch bool) error

ClosePullRequests closes a list of pull requests.

func (*Github) CreatePullRequest

func (gh *Github) CreatePullRequest(ctx context.Context, title, head, base, body string) (string, int, error)

CreatePullRequest creates a new pull request.

func (*Github) CreatePullRequestComment

func (gh *Github) CreatePullRequestComment(ctx context.Context, id int, text string) error

CreatePullRequestComment creates a new comment on a given pull request.

func (*Github) FindPullRequests

func (gh *Github) FindPullRequests(ctx context.Context, owner, titleMatch string) (prs []*PullRequest, err error)

FindPullRequests searches and returns a list of pull requests.

func (*Github) PullRequestFiles

func (gh *Github) PullRequestFiles(ctx context.Context, number int) (created, removed, modified []string, err error)

PullRequestFiles takes a github diffURL and returns a list of files affected by this pull request. Example diff url: https://github.com/owner/project/pull/95.diff

func (*Github) RemoveRemoveRef

func (gh *Github) RemoveRemoveRef(ctx context.Context, ref string) error

RemoveRemoveRef removes a remote reference.

func (*Github) RequestReviewers

func (gh *Github) RequestReviewers(pr int, names []string) error

RequestReviewers add reviewers to a PR.

type Option

type Option func(gh *Github) error

Option is a functional parameter

func WithJWTTransport

func WithJWTTransport(owner, repo, githubAPI string, integrationID, installationID int, privateKeyBody []byte) Option

WithJWTTransport configures HTTP transport to use installations token based on JWT.

type PullRequest

type PullRequest struct {
	Number    int
	Branch    string
	SHA       string
	CreatedAt *time.Time

	CreatedFiles  []string
	RemovedFiles  []string
	ModifiedFiles []string
}

PullRequest is an abstraction represents a PR.

func (PullRequest) AllFiles

func (pr PullRequest) AllFiles() []string

AllFiles returns a one slice for all files in pull requested (created, removed and modified)

Jump to

Keyboard shortcuts

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