github

package
v0.0.0-...-aa69371 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2015 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLabelsWithPrefix

func GetLabelsWithPrefix(labels []github.Label, prefix string) []string

GetLabelsWithPrefix will return a slice of all label names in `labels` which start with given prefix.

func HasLabel

func HasLabel(labels []github.Label, name string) bool

HasLabel returns if the label `name` is in the array of `labels`

func HasLabels

func HasLabels(labels []github.Label, names []string) bool

HasLabels returns if all of the label `names` are in the array of `labels`

func LabelTime

func LabelTime(label string, events []github.IssueEvent) *time.Time

LabelTime returns the last time the request label was added to an issue. If the label was never added you will get the 0 time.

func LastModifiedTime

func LastModifiedTime(commits []github.RepositoryCommit) *time.Time

LastModifiedTime returns the date of the latest commit

Types

type Config

type Config struct {
	Org     string
	Project string

	RateLimit      float32
	RateLimitBurst int

	Token     string
	TokenFile string

	MinPRNumber int
	MaxPRNumber int

	// If true, don't make any mutating API calls
	DryRun bool

	// Defaults to 30 seconds.
	PendingWaitTime *time.Duration
	// contains filtered or unexported fields
}

Config is how we are configured to talk to github and provides access methods for doing so.

func (*Config) AddLabels

func (config *Config) AddLabels(prNum int, labels []string) error

AddLabels will add all of the named `labels` to the PR

func (*Config) AddRootFlags

func (config *Config) AddRootFlags(cmd *cobra.Command)

AddRootFlags will add all of the flags needed for the github config to the cobra command

func (*Config) AssignPR

func (config *Config) AssignPR(prNum int, owner string) error

AssignPR will assign `prNum` to the `owner` where the `owner` is asignee's github login

func (*Config) ClosePR

func (config *Config) ClosePR(pr *github.PullRequest) error

ClosePR will close the Given PR

func (*Config) ForEachIssueDo

func (config *Config) ForEachIssueDo(labels []string, fn IssueFunction) error

ForEachIssueDo will call the provided IssueFunction once for each issue which has the labels provided in `labels`

func (*Config) ForEachPRDo

func (config *Config) ForEachPRDo(labels []string, fn PRFunction) error

ForEachPRDo will call the provided PRFunction once for each issue which has the labels provided in `labels`

func (*Config) GetAllEventsForPR

func (config *Config) GetAllEventsForPR(prNum int) ([]github.IssueEvent, error)

GetAllEventsForPR returns a list of all events for a given pr.

func (*Config) GetFileContents

func (config *Config) GetFileContents(file, sha string) (string, error)

GetFileContents will return the contents of the `file` in the repo at `sha` as a string

func (*Config) GetFilledCommits

func (config *Config) GetFilledCommits(prNum int) ([]github.RepositoryCommit, error)

GetFilledCommits returns all of the commits for a given PR

func (*Config) GetPR

func (config *Config) GetPR(prNum int) (*github.PullRequest, error)

GetPR will return a pull request based on the provided number. This may be useful if some of the information in the provided PR was not filled out when it was retrieved.

func (*Config) GetStatus

func (config *Config) GetStatus(pr *github.PullRequest, requiredContexts []string) (string, error)

GetStatus gets the current status of a PR.

  • If any member of the 'requiredContexts' list is missing, it is 'incomplete'
  • If any is 'pending', the PR is 'pending'
  • If any is 'error', the PR is in 'error'
  • If any is 'failure', the PR is 'failure'
  • Otherwise the PR is 'success'

func (*Config) GetUser

func (config *Config) GetUser(login string) (*github.User, error)

GetUser will return information about the github user with the given login name

func (*Config) IsPRMergeable

func (config *Config) IsPRMergeable(pr *github.PullRequest) (bool, error)

IsPRMergeable will return if the PR is mergeable. It will pause and get the PR again if github did not respond the first time. So the hopefully github will have a response the second time. If we have no answer twice, we return false

func (*Config) IsStatusSuccess

func (config *Config) IsStatusSuccess(pr *github.PullRequest, requiredContexts []string) bool

IsStatusSuccess makes sure that the combined status for all commits in a PR is 'success'

func (*Config) LastModifiedTime

func (config *Config) LastModifiedTime(prNum int) (*time.Time, error)

LastModifiedTime returns the time the last commit was made BUG: this should probably return the last time a git push happened or something like that.

func (*Config) MergePR

func (config *Config) MergePR(pr *github.PullRequest, who string) error

MergePR will merge the given PR, duh "who" is who is doing the merging, like "submit-queue"

func (*Config) OpenPR

func (config *Config) OpenPR(pr *github.PullRequest, numTries int) error

OpenPR will attempt to open the given PR. It will attempt to reopen the pr `numTries` before returning an error and giving up.

func (*Config) PreExecute

func (config *Config) PreExecute() error

PreExecute will initialize the Config. It MUST be run before the config may be used to get information from Github

func (*Config) RemoveLabel

func (config *Config) RemoveLabel(prNum int, label string) error

RemoveLabel will remove the `label` from the PR

func (*Config) ResetAPICount

func (config *Config) ResetAPICount()

ResetAPICount will both reset the counters of how many api calls have been made but will also print the information from the last run.

func (*Config) SetClient

func (config *Config) SetClient(client *github.Client)

SetClient should ONLY be used by testing. Normal commands should use PreExecute()

func (*Config) UsersWithAccess

func (config *Config) UsersWithAccess() ([]github.User, []github.User, error)

UsersWithAccess returns two sets of users. The first set are users with push access. The second set is the specific set of user with pull access. If the repo is public all users will have pull access, but some with have it explicitly

func (*Config) WaitForNotPending

func (config *Config) WaitForNotPending(pr *github.PullRequest) error

WaitForNotPending will check if the github status is "pending" (CI still running) if so it will sleep and try again until all status hooks have complete

func (*Config) WaitForPending

func (config *Config) WaitForPending(pr *github.PullRequest) error

WaitForPending will wait for a PR to move into Pending. This is useful because the request to test a PR again is asynchronous with the PR actually moving into a pending state

func (*Config) WriteComment

func (config *Config) WriteComment(prNum int, msg string) error

WriteComment will send the `msg` as a comment to the specified PR

type IssueFunction

type IssueFunction func(*github.Issue) error

IssueFunction is the type that must be implemented and passed to ForEachIssueDo

type PRFunction

type PRFunction func(*github.PullRequest, *github.Issue) error

PRFunction is the type that must be implemented and passed to ForEachPRDo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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