Documentation ¶
Index ¶
- func GetLabelsWithPrefix(labels []github.Label, prefix string) []string
- func HasLabel(labels []github.Label, name string) bool
- func HasLabels(labels []github.Label, names []string) bool
- func LabelTime(label string, events []github.IssueEvent) *time.Time
- func LastModifiedTime(commits []github.RepositoryCommit) *time.Time
- type Config
- func (config *Config) AddLabels(prNum int, labels []string) error
- func (config *Config) AddRootFlags(cmd *cobra.Command)
- func (config *Config) AssignPR(prNum int, owner string) error
- func (config *Config) ClosePR(pr *github.PullRequest) error
- func (config *Config) ForEachIssueDo(labels []string, fn IssueFunction) error
- func (config *Config) ForEachPRDo(labels []string, fn PRFunction) error
- func (config *Config) GetAllEventsForPR(prNum int) ([]github.IssueEvent, error)
- func (config *Config) GetFileContents(file, sha string) (string, error)
- func (config *Config) GetFilledCommits(prNum int) ([]github.RepositoryCommit, error)
- func (config *Config) GetPR(prNum int) (*github.PullRequest, error)
- func (config *Config) GetStatus(pr *github.PullRequest, requiredContexts []string) (string, error)
- func (config *Config) GetUser(login string) (*github.User, error)
- func (config *Config) IsPRMergeable(pr *github.PullRequest) (bool, error)
- func (config *Config) IsStatusSuccess(pr *github.PullRequest, requiredContexts []string) bool
- func (config *Config) LastModifiedTime(prNum int) (*time.Time, error)
- func (config *Config) MergePR(pr *github.PullRequest, who string) error
- func (config *Config) OpenPR(pr *github.PullRequest, numTries int) error
- func (config *Config) PreExecute() error
- func (config *Config) RemoveLabel(prNum int, label string) error
- func (config *Config) ResetAPICount()
- func (config *Config) SetClient(client *github.Client)
- func (config *Config) UsersWithAccess() ([]github.User, []github.User, error)
- func (config *Config) WaitForNotPending(pr *github.PullRequest) error
- func (config *Config) WaitForPending(pr *github.PullRequest) error
- func (config *Config) WriteComment(prNum int, msg string) error
- type IssueFunction
- type PRFunction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLabelsWithPrefix ¶
GetLabelsWithPrefix will return a slice of all label names in `labels` which start with given prefix.
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) AddRootFlags ¶
AddRootFlags will add all of the flags needed for the github config to the cobra command
func (*Config) AssignPR ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
PreExecute will initialize the Config. It MUST be run before the config may be used to get information from Github
func (*Config) RemoveLabel ¶
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 ¶
SetClient should ONLY be used by testing. Normal commands should use PreExecute()
func (*Config) UsersWithAccess ¶
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
type IssueFunction ¶
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