github

package
v0.0.0-...-5952ad4 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPending = "pending"
	StatusSuccess = "success"
	StatusError   = "error"
	StatusFailure = "failure"
)

These are possible State entries for a Status.

View Source
const (
	ReactionThumbsUp   = "+1"
	ReactionThumbsDown = "-1"
	ReactionLaugh      = "laugh"
	ReactionConfused   = "confused"
	ReactionHeart      = "heart"
	ReactionHooray     = "hooray"
)

Possible contents for reactions.

Variables

This section is empty.

Functions

func PayloadSignature

func PayloadSignature(payload []byte, key []byte) string

PayloadSignature returns the signature that matches the payload.

func ValidatePayload

func ValidatePayload(payload []byte, sig string, key []byte) bool

ValidatePayload ensures that the request payload signature matches the key.

Types

type Client

type Client struct {
	// If Logger is non-nil, log all method calls with it.
	Logger Logger
	// contains filtered or unexported fields
}

func NewClient

func NewClient(botName, token string) *Client

NewClient creates a new fully operational GitHub client.

func NewDryRunClient

func NewDryRunClient(botName, token string) *Client

NewDryRunClient creates a new client that will not perform mutating actions such as setting statuses or commenting, but it will still query GitHub and use up API tokens.

func NewFakeClient

func NewFakeClient(botName string) *Client

NewFakeClient creates a new client that will not perform any actions at all.

func (*Client) AddLabel

func (c *Client) AddLabel(org, repo string, number int, label string) error

func (*Client) AssignIssue

func (c *Client) AssignIssue(org, repo string, number int, logins []string) error

func (*Client) BotName

func (c *Client) BotName() string

func (*Client) CloseIssue

func (c *Client) CloseIssue(org, repo string, number int) error

func (*Client) CreateComment

func (c *Client) CreateComment(org, repo string, number int, comment string) error

CreateComment creates a comment on the issue.

func (*Client) CreateCommentReaction

func (c *Client) CreateCommentReaction(org, repo string, ID int, reaction string) error

func (*Client) CreateIssueReaction

func (c *Client) CreateIssueReaction(org, repo string, ID int, reaction string) error

func (*Client) CreateStatus

func (c *Client) CreateStatus(org, repo, ref string, s Status) error

CreateStatus creates or updates the status of a commit.

func (*Client) DeleteComment

func (c *Client) DeleteComment(org, repo string, ID int) error

DeleteComment deletes the comment.

func (*Client) EditComment

func (c *Client) EditComment(org, repo string, ID int, comment string) error

func (*Client) FindIssues

func (c *Client) FindIssues(query string) ([]Issue, error)

FindIssues uses the github search API to find issues which match a particular query. TODO(foxish): we should accept map[string][]string and use net/url properly.

func (*Client) GetCombinedStatus

func (c *Client) GetCombinedStatus(org, repo, ref string) (*CombinedStatus, error)

GetCombinedStatus returns the latest statuses for a given ref.

func (*Client) GetIssueLabels

func (c *Client) GetIssueLabels(org, repo string, number int) ([]Label, error)

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(org, repo string, number int) (*PullRequest, error)

GetPullRequest gets a pull request.

func (*Client) GetPullRequestChanges

func (c *Client) GetPullRequestChanges(pr PullRequest) ([]PullRequestChange, error)

GetPullRequestChanges gets a list of files modified in a pull request.

func (*Client) GetRef

func (c *Client) GetRef(org, repo, ref string) (string, error)

GetRef returns the SHA of the given ref, such as "heads/master".

func (*Client) GetRepoLabels

func (c *Client) GetRepoLabels(org, repo string) ([]Label, error)

func (*Client) IsMember

func (c *Client) IsMember(org, user string) (bool, error)

IsMember returns whether or not the user is a member of the org.

func (*Client) ListIssueComments

func (c *Client) ListIssueComments(org, repo string, number int) ([]IssueComment, error)

ListIssueComments returns all comments on an issue. This may use more than one API token.

func (*Client) RemoveLabel

func (c *Client) RemoveLabel(org, repo string, number int, label string) error

func (*Client) ReopenIssue

func (c *Client) ReopenIssue(org, repo string, number int) error

ReopenIssue re-opens the existing, closed issue provided

func (*Client) RequestReview

func (c *Client) RequestReview(org, repo string, number int, logins []string) error

RequestReview tries to add the users listed in 'logins' as requested reviewers of the specified PR. If any user in the 'logins' slice is not a contributor of the repo, the entire POST will fail without adding any reviewers. The github API response does not specify which user(s) were invalid so if we fail to request reviews from the members of 'logins' we try to request reviews from each member individually. We try first with all users in 'logins' for efficiency in the common case.

func (*Client) UnassignIssue

func (c *Client) UnassignIssue(org, repo string, number int, logins []string) error

func (*Client) UnrequestReview

func (c *Client) UnrequestReview(org, repo string, number int, logins []string) error

UnrequestReview tries to remove the users listed in 'logins' from the requested reviewers of the specified PR. The github API treats deletions of review requests differently than creations. Specifically, if 'logins' contains a user that isn't a requested reviewer, other users that are valid are still removed. Furthermore, the API response lists the set of requested reviewers after the deletion (unlike request creations), so we can determine if each deletion was successful. The API responds with http status code 200 no matter what the content of 'logins' is.

type CombinedStatus

type CombinedStatus struct {
	Statuses []Status `json:"statuses"`
}

CombinedStatus is the latest statuses for a ref.

type Commit

type Commit struct {
	ID       string   `json:"id"`
	Message  string   `json:"message"`
	Added    []string `json:"added"`
	Removed  []string `json:"removed"`
	Modified []string `json:"modified"`
}

type ExtraUsers

type ExtraUsers struct {
	Users []string
	// contains filtered or unexported fields
}

func (ExtraUsers) Error

func (e ExtraUsers) Error() string

type Issue

type Issue struct {
	User      User    `json:"user"`
	Number    int     `json:"number"`
	Title     string  `json:"title"`
	State     string  `json:"state"`
	HTMLURL   string  `json:"html_url"`
	Labels    []Label `json:"labels"`
	Assignees []User  `json:"assignees"`
	Body      string  `json:"body"`

	// This will be non-nil if it is a pull request.
	PullRequest *struct{} `json:"pull_request,omitempty"`
}

func (Issue) HasLabel

func (i Issue) HasLabel(labelToFind string) bool

func (Issue) IsAssignee

func (i Issue) IsAssignee(login string) bool

func (Issue) IsAuthor

func (i Issue) IsAuthor(login string) bool

func (Issue) IsPullRequest

func (i Issue) IsPullRequest() bool

type IssueComment

type IssueComment struct {
	ID      int    `json:"id,omitempty"`
	Body    string `json:"body"`
	User    User   `json:"user,omitempty"`
	HTMLURL string `json:"html_url,omitempty"`
}

type IssueCommentEvent

type IssueCommentEvent struct {
	Action  string       `json:"action"`
	Issue   Issue        `json:"issue"`
	Comment IssueComment `json:"comment"`
	Repo    Repo         `json:"repository"`
}

type IssueEvent

type IssueEvent struct {
	Action string `json:"action"`
	Issue  Issue  `json:"issue"`
	Repo   Repo   `json:"repository"`
}

type IssuesSearchResult

type IssuesSearchResult struct {
	Total  int     `json:"total_count,omitempty"`
	Issues []Issue `json:"items,omitempty"`
}

IssuesSearchResult represents the result of an issues search.

type Label

type Label struct {
	URL   string `json:"url"`
	Name  string `json:"name"`
	Color string `json:"color"`
}

type Logger

type Logger interface {
	Printf(s string, v ...interface{})
}

type MissingUsers

type MissingUsers struct {
	Users []string
	// contains filtered or unexported fields
}

func (MissingUsers) Error

func (m MissingUsers) Error() string

type PullRequest

type PullRequest struct {
	Number             int               `json:"number"`
	HTMLURL            string            `json:"html_url"`
	User               User              `json:"user"`
	Base               PullRequestBranch `json:"base"`
	Head               PullRequestBranch `json:"head"`
	Body               string            `json:"body"`
	RequestedReviewers []User            `json:"requested_reviewers"`
	Assignees          []User            `json:"assignees"`
}

PullRequest contains information about a PullRequest.

type PullRequestBranch

type PullRequestBranch struct {
	Ref  string `json:"ref"`
	SHA  string `json:"sha"`
	Repo Repo   `json:"repo"`
}

PullRequestBranch contains information about a particular branch in a PR.

type PullRequestChange

type PullRequestChange struct {
	SHA       string `json:"sha"`
	Filename  string `json:"filename"`
	Status    string `json:"added"`
	Additions int    `json:"additions"`
	Deletions int    `json:"deletions"`
	Changes   int    `json:"changes"`
	Patch     string `json:"patch"`
}

PullRequestChange contains information about what a PR changed.

type PullRequestEvent

type PullRequestEvent struct {
	Action      string      `json:"action"`
	Number      int         `json:"number"`
	PullRequest PullRequest `json:"pull_request"`
	Label       Label       `json:"label"`
}

PullRequestEvent is what GitHub sends us when a PR is changed.

type PushEvent

type PushEvent struct {
	Ref     string   `json:"ref"`
	Before  string   `json:"before"`
	After   string   `json:"after"`
	Commits []Commit `json:"commits"`
	Repo    Repo     `json:"repository"`
}

func (PushEvent) Branch

func (pe PushEvent) Branch() string

type Reaction

type Reaction struct {
	Content string `json:"content"`
}

type Repo

type Repo struct {
	Owner    User   `json:"owner"`
	Name     string `json:"name"`
	FullName string `json:"full_name"`
	HTMLURL  string `json:"html_url"`
}

Repo contains general repository information.

type Review

type Review struct {
	ID      int    `json:"id"`
	User    User   `json:"user"`
	Body    string `json:"body"`
	State   string `json:"state"`
	HTMLURL string `json:"html_url"`
}

Review describes a Pull Request review.

type ReviewComment

type ReviewComment struct {
	ID       int    `json:"id"`
	ReviewID int    `json:"pull_request_review_id"`
	User     User   `json:"user"`
	Body     string `json:"body"`
	Path     string `json:"path"`
	HTMLURL  string `json:"html_url"`
}

ReviewComment describes a Pull Request review.

type ReviewCommentEvent

type ReviewCommentEvent struct {
	Action      string        `json:"action"`
	PullRequest PullRequest   `json:"pull_request"`
	Repo        Repo          `json:"repository"`
	Comment     ReviewComment `json:"comment"`
}

ReviewCommentEvent is what GitHub sends us when a PR review comment is changed.

type ReviewEvent

type ReviewEvent struct {
	Action      string      `json:"action"`
	PullRequest PullRequest `json:"pull_request"`
	Repo        Repo        `json:"repository"`
	Review      Review      `json:"review"`
}

ReviewEvent is what GitHub sends us when a PR review is changed.

type Status

type Status struct {
	State       string `json:"state"`
	TargetURL   string `json:"target_url,omitempty"`
	Description string `json:"description,omitempty"`
	Context     string `json:"context,omitempty"`
}

Status is used to set a commit status line.

type StatusEvent

type StatusEvent struct {
	SHA         string `json:"sha,omitempty"`
	State       string `json:"state,omitempty"`
	Description string `json:"description,omitempty"`
	TargetURL   string `json:"target_url,omitempty"`
	ID          int    `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	Context     string `json:"context,omitempty"`
	Sender      User   `json:"sender,omitempty"`
	Repo        Repo   `json:"repository,omitempty"`
}

type User

type User struct {
	Login string `json:"login"`
	Name  string `json:"name"`
}

User is a GitHub user account.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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