gh

package
v0.0.0-...-ddb4624 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetToken

func GetToken(c *configuration.Config) string

GetToken returns the GitHub API token to use.

func HasAllLabels

func HasAllLabels(labels []string, issueLabels []github.Label) bool

HasAllLabels returns true if a collection of labels contains all of the specified collection of labels.

func HasAnyLabels

func HasAnyLabels(labels []string, issueLabels []github.Label) bool

HasAnyLabels returns true if a collection of labels contains any of the specified collection of labels.

func HasFailingCILabel

func HasFailingCILabel(labels []github.Label) bool

HasFailingCILabel returns true if a collection of labels contains the particular label indicating test failures.

func HasLabel

func HasLabel(label string, issueLabels []github.Label) bool

HasLabel returns true if a collection of labels contains the specified label.

Types

type Client

type Client interface {
	Issues() IssuesService
	PullRequests() PullRequestsService
	Repositories() RepositoriesService
	Search() SearchService
}

Client allows us to wrap the use of the go-github library in order to be able to mock it in tests.

func MakeClient

func MakeClient(c *configuration.Config) Client

MakeClient returns a new client instance for the specified configuration.

type DefaultClient

type DefaultClient struct {
	Client *github.Client
}

DefaultClient is the default implementation for a GitHub client.

func (DefaultClient) Issues

func (d DefaultClient) Issues() IssuesService

Issues returns the issue service instance.

func (DefaultClient) PullRequests

func (d DefaultClient) PullRequests() PullRequestsService

PullRequests returns the pull request service instance.

func (DefaultClient) Repositories

func (d DefaultClient) Repositories() RepositoriesService

Repositories returns the repository service instance.

func (DefaultClient) Search

func (d DefaultClient) Search() SearchService

Search returns the search service instance.

type IssuesService

type IssuesService interface {
	// Issue API.
	Edit(owner string, repo string, number int, issue *github.IssueRequest) (*github.Issue, *github.Response, error)
	Get(owner string, repo string, number int) (*github.Issue, *github.Response, error)
	ListByRepo(owner string, repo string, opt *github.IssueListByRepoOptions) ([]*github.Issue, *github.Response, error)

	// Comments API.
	CreateComment(owner string, repo string, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error)
	DeleteComment(owner string, repo string, id int) (*github.Response, error)
	ListComments(owner string, repo string, number int, opt *github.IssueListCommentsOptions) ([]*github.IssueComment, *github.Response, error)

	// Label API.
	AddLabelsToIssue(owner string, repo string, number int, labels []string) ([]*github.Label, *github.Response, error)
	RemoveLabelForIssue(owner string, repo string, number int, label string) (*github.Response, error)

	// Milestones API.
	ListMilestones(owner string, repo string, opt *github.MilestoneListOptions) ([]*github.Milestone, *github.Response, error)
}

IssuesService is the interface to the GitHub issue service.

type Item

type Item struct {
	Issue       *github.Issue
	PullRequest *github.PullRequest
}

Item is a union type that can encapsulate either a github.Issue or a github.PullRequest. This allows to have a single Operation interface and let the implementation handle according to its capabilities.

func MakeIssueItem

func MakeIssueItem(issue *github.Issue) Item

MakeIssueItem create an Item wrapper around a GitHub issue.

func MakePullRequestItem

func MakePullRequestItem(pullRequest *github.PullRequest) Item

MakePullRequestItem create an Item wrapper around a GitHub pull request.

func (Item) Body

func (i Item) Body() string

Body returns the text body of the item.

func (*Item) GetRelatedIssue

func (i *Item) GetRelatedIssue(client Client) (*github.Issue, error)

GetRelatedIssue retrieves and return the GitHub issue related to a pull request. This function will fail when called on a GitHub issue.

func (Item) IsIssue

func (i Item) IsIssue() bool

IsIssue returns whether the item is strictly a GitHub issue (i.e., not the issue object of a corresponding pull request).

func (Item) IsNil

func (i Item) IsNil() bool

IsNil returns true when the item is not initialized.

func (Item) IsPullRequest

func (i Item) IsPullRequest() bool

IsPullRequest returns whether the item is a GitHub pull request.

func (*Item) Number

func (i *Item) Number() int

Number returns the number of the item.

func (*Item) Repository

func (i *Item) Repository() string

Repository returns the repository full name of the item. In the case of a pull request, this is the destination repository.

func (*Item) Title

func (i *Item) Title() string

Title returns the title of the item.

func (*Item) Type

func (i *Item) Type() string

Type returns a string representation of the GitHub item type.

type PullRequestsService

type PullRequestsService interface {
	// Pull requests API.
	Get(owner string, repo string, number int) (*github.PullRequest, *github.Response, error)
	List(owner string, repo string, opt *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error)
	ListFiles(owner string, repo string, number int, opt *github.ListOptions) ([]*github.CommitFile, *github.Response, error)

	// Commits API.
	ListCommits(owner string, repo string, number int, opt *github.ListOptions) ([]*github.RepositoryCommit, *github.Response, error)
}

PullRequestsService is the interface to the GitHub pull request service.

type RepoStatus

type RepoStatus struct {
	CreatedAt time.Time
	State     string
}

RepoStatus is the status of a repository at a particular reference.

type RepositoriesService

type RepositoriesService interface {
	// Branches API.
	GetBranch(owner, repo, branch string) (*github.Branch, *github.Response, error)

	// Statuses API.
	CreateStatus(owner, repo, ref string, sts *github.RepoStatus) (*github.RepoStatus, *github.Response, error)
	ListStatuses(owner, repo, ref string, opt *github.ListOptions) ([]*github.RepoStatus, *github.Response, error)
}

RepositoriesService is the interface to the GitHub repositories service.

type SearchService

type SearchService interface {
	Issues(query string, opt *github.SearchOptions) (*github.IssuesSearchResult, *github.Response, error)
}

SearchService is the interface to the GitHub search service.

type StatusSnapshot

type StatusSnapshot map[string]RepoStatus

StatusSnapshot is a collection of statuses indexed by the corresponding configuration name.

func GetLatestStatuses

func GetLatestStatuses(statuses []*github.RepoStatus) StatusSnapshot

GetLatestStatuses returns the selection of the latest status for each configuration.

func (*StatusSnapshot) HasFailures

func (s *StatusSnapshot) HasFailures() bool

HasFailures returns any whether any of the statuses are in a failed state.

Jump to

Keyboard shortcuts

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