{"modulePath":"github.com/vungle/contrib","version":"v0.0.0-20160411181928-7ce7f99f6f22","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package github\n\n## Functions\n\n```go\nfunc GetLabelsWithPrefix(labels []github.Label, prefix string) []string\n```\nGetLabelsWithPrefix will return a slice of all label names in \\`labels\\` which start with given prefix.\n\n## Types\n\n```go\ntype Config struct {\n\tOrg     string\n\tProject string\n\n\tToken     string\n\tTokenFile string\n\n\tMinPRNumber int\n\tMaxPRNumber int\n\n\t// If true, don't make any mutating API calls\n\tDryRun bool\n\n\t// Defaults to 30 seconds.\n\tPendingWaitTime *time.Duration\n\t// contains filtered or unexported fields\n}\n```\nConfig is how we are configured to talk to github and provides access methods for doing so.\n\n```go\nfunc (config *Config) AddRootFlags(cmd *cobra.Command)\n```\nAddRootFlags will add all of the flags needed for the github config to the cobra command\n\n```go\nfunc (config *Config) ForEachIssueDo(fn MungeFunction) error\n```\nForEachIssueDo will run for each Issue in the project that matches:\n\n  - pr.Number \u003e= minPRNumber\n  - pr.Number \\\u003c= maxPRNumber\n\n```go\nfunc (config *Config) GetDebugStats() DebugStats\n```\nGetDebugStats returns information about the bot iself. Things like how many API calls has it made, how many of each type, etc.\n\n```go\nfunc (config *Config) GetObject(num int) (*MungeObject, error)\n```\nGetObject will return an object (with only the issue filled in)\n\n```go\nfunc (config *Config) GetUser(login string) (*github.User, error)\n```\nGetUser will return information about the github user with the given login name\n\n```go\nfunc (config *Config) ListAllIssues(listOpts *github.IssueListByRepoOptions) ([]*github.Issue, error)\n```\nListAllIssues grabs all issues matching the options, so you don't have to worry about paging. Enforces some constraints, like min/max PR number and having a valid user.\n\n```go\nfunc (config *Config) NextExpectedUpdate(t time.Time)\n```\nNextExpectedUpdate will set the debug information concerning when the mungers are likely to run again.\n\n```go\nfunc (config *Config) PreExecute() error\n```\nPreExecute will initialize the Config. It MUST be run before the config may be used to get information from Github\n\n```go\nfunc (config *Config) ResetAPICount()\n```\nResetAPICount will both reset the counters of how many api calls have been made but will also print the information from the last run.\n\n```go\nfunc (config *Config) SetClient(client *github.Client)\n```\nSetClient should ONLY be used by testing. Normal commands should use PreExecute()\n\n```go\nfunc (config *Config) UsersWithAccess() ([]github.User, []github.User, error)\n```\nUsersWithAccess 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\n\n```go\ntype DebugStats struct {\n\tAnalytics      analytics\n\tAPIPerSec      float64\n\tAPICount       int\n\tCachedAPICount int\n\tNextLoopTime   time.Time\n\tLimitRemaining int\n\tLimitResetTime time.Time\n}\n```\nDebugStats is a structure that tells information about how we have interacted with github\n\n```go\ntype MungeFunction func(*MungeObject) error\n```\nMungeFunction is the type that must be implemented and passed to ForEachIssueDo\n\n```go\ntype MungeObject struct {\n\tIssue *github.Issue\n\t// contains filtered or unexported fields\n}\n```\nMungeObject is the object that mungers deal with. It is a combination of different github API objects.\n\n```go\nfunc TestObject(config *Config, issue *github.Issue, pr *github.PullRequest, commits []github.RepositoryCommit, events []github.IssueEvent) *MungeObject\n```\nTestObject should NEVER be used outside of \\_test.go code. It creates a MungeObject with the given fields. Normally these should be filled in lazily as needed\n\n```go\nfunc (obj *MungeObject) AddLabels(labels []string) error\n```\nAddLabels will add all of the named \\`labels\\` to the PR\n\n```go\nfunc (obj *MungeObject) AssignPR(owner string) error\n```\nAssignPR will assign \\`prNum\\` to the \\`owner\\` where the \\`owner\\` is asignee's github login\n\n```go\nfunc (obj *MungeObject) ClosePR() error\n```\nClosePR will close the Given PR\n\n```go\nfunc (obj *MungeObject) DeleteComment(comment *github.IssueComment) error\n```\nDeleteComment will remove the specified comment\n\n```go\nfunc (obj *MungeObject) GetCommits() ([]github.RepositoryCommit, error)\n```\nGetCommits returns all of the commits for a given PR\n\n```go\nfunc (obj *MungeObject) GetEvents() ([]github.IssueEvent, error)\n```\nGetEvents returns a list of all events for a given pr.\n\n```go\nfunc (obj *MungeObject) GetFileContents(file, sha string) (string, error)\n```\nGetFileContents will return the contents of the \\`file\\` in the repo at \\`sha\\` as a string\n\n```go\nfunc (obj *MungeObject) GetPR() (*github.PullRequest, error)\n```\nGetPR will return the PR of the object.\n\n```go\nfunc (obj *MungeObject) GetStatus(context string) *github.RepoStatus\n```\nGetStatus returns the actual requested status, or nil if not found\n\n```go\nfunc (obj *MungeObject) GetStatusState(requiredContexts []string) string\n```\nGetStatusState gets the current status of a PR.\n\n  - If any member of the 'requiredContexts' list is missing, it is 'incomplete'\n  - If any is 'pending', the PR is 'pending'\n  - If any is 'error', the PR is in 'error'\n  - If any is 'failure', the PR is 'failure'\n  - Otherwise the PR is 'success'\n\n```go\nfunc (obj *MungeObject) GetStatusTime(context string) *time.Time\n```\nGetStatusTime returns when the status was set\n\n```go\nfunc (obj *MungeObject) HasLabel(name string) bool\n```\nHasLabel returns if the label \\`name\\` is in the array of \\`labels\\`\n\n```go\nfunc (obj *MungeObject) HasLabels(names []string) bool\n```\nHasLabels returns if all of the label \\`names\\` are in the array of \\`labels\\`\n\n```go\nfunc (obj *MungeObject) IsForBranch(branch string) bool\n```\nIsForBranch return true if the object is a PR for a branch with the given name. It return false if it is not a pr, it isn't against the given branch, or we can't tell\n\n```go\nfunc (obj *MungeObject) IsMergeable() (bool, error)\n```\nIsMergeable 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\n\n```go\nfunc (obj *MungeObject) IsMerged() (bool, error)\n```\nIsMerged returns if the issue in question was already merged\n\n```go\nfunc (obj *MungeObject) IsPR() bool\n```\nIsPR returns if the obj is a PR or an Issue.\n\n```go\nfunc (obj *MungeObject) IsStatusSuccess(requiredContexts []string) bool\n```\nIsStatusSuccess makes sure that the combined status for all commits in a PR is 'success'\n\n```go\nfunc (obj *MungeObject) LabelCreator(label string) string\n```\nLabelCreator returns the login name of the user who (last) created the given label\n\n```go\nfunc (obj *MungeObject) LabelSet() sets.String\n```\nLabelSet returns the name of all of he labels applied to the object as a kubernetes string set.\n\n```go\nfunc (obj *MungeObject) LabelTime(label string) *time.Time\n```\nLabelTime returns the last time the request label was added to an issue. If the label was never added you will get the 0 time.\n\n```go\nfunc (obj *MungeObject) LastModifiedTime() *time.Time\n```\nLastModifiedTime returns the time the last commit was made BUG: this should probably return the last time a git push happened or something like that.\n\n```go\nfunc (obj *MungeObject) ListComments(number int) ([]github.IssueComment, error)\n```\nListComments returns all comments for the issue/PR in question\n\n```go\nfunc (obj *MungeObject) MergePR(who string) error\n```\nMergePR will merge the given PR, duh \"who\" is who is doing the merging, like \"submit-queue\"\n\n```go\nfunc (obj *MungeObject) OpenPR(numTries int) error\n```\nOpenPR will attempt to open the given PR. It will attempt to reopen the pr \\`numTries\\` before returning an error and giving up.\n\n```go\nfunc (obj *MungeObject) Priority() int\n```\nPriority returns the priority an issue was labeled with. The labels must take the form 'priority/P?\\[0-9]+' or math.MaxInt32 if unset\n\n```go\nfunc (obj *MungeObject) Refresh() error\n```\nRefresh will refresh the Issue (and PR if this is a PR) (not the commits or events)\n\n```go\nfunc (obj *MungeObject) RemoveLabel(label string) error\n```\nRemoveLabel will remove the \\`label\\` from the PR\n\n```go\nfunc (obj *MungeObject) SetStatus(state, url, description, context string) error\n```\nSetStatus allowes you to set the Github Status\n\n```go\nfunc (obj *MungeObject) WaitForNotPending(requiredContexts []string) error\n```\nWaitForNotPending will check if the github status is \"pending\" (CI still running) if so it will sleep and try again until all required status hooks have complete\n\n```go\nfunc (obj *MungeObject) WaitForPending(requiredContexts []string) error\n```\nWaitForPending 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\n\n```go\nfunc (obj *MungeObject) WriteComment(msg string) error\n```\nWriteComment will send the \\`msg\\` as a comment to the specified PR\n\n","path":"github.com/vungle/contrib/mungegithub/github","name":"github","synopsis":"","isRedistributable":true}
