github

package
v0.0.0-...-7a0fe3b Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2015 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NeedsOKToMergeLabel = "needs-ok-to-merge"
)

Variables

This section is empty.

Functions

func ForEachCandidatePRDo

func ForEachCandidatePRDo(client *github.Client, user, project string, fn PRFunction, once bool, config *FilterConfig) error

For each PR in the project that matches:

  • pr.Number > minPRNumber
  • is mergeable
  • has labels "cla: yes", "lgtm"
  • combinedStatus = 'success' (e.g. all hooks have finished success in github)

Run the specified function

func GetAllEventsForPR

func GetAllEventsForPR(client *github.Client, user, project string, prNumber int) ([]github.IssueEvent, error)

func GetStatus

func GetStatus(client *github.Client, user, project string, prNumber int, requiredContexts []string) (string, error)

Gets the current status of a PR by introspecting the status of the commits in the PR. The rules are:

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

func HasLabel

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

func HasLabels

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

func MakeClient

func MakeClient(token string) *github.Client

func UsersWithCommit

func UsersWithCommit(client *github.Client, org, project string) ([]string, error)

func ValidateStatus

func ValidateStatus(client *github.Client, user, project string, prNumber int, requiredContexts []string, waitOnPending bool) (bool, error)

Make sure that the combined status for all commits in a PR is 'success' if 'waitForPending' is true, this function will wait until the PR is no longer pending (all checks have run)

func WaitForPending

func WaitForPending(client *github.Client, user, project string, prNumber int) error

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 TODO: add a timeout

Types

type FilterConfig

type FilterConfig struct {
	MinPRNumber int

	// non-committer users believed safe
	AdditionalUserWhitelist []string

	// Committers are static here in case they can't be gotten dynamically;
	// they do not need to be whitelisted.
	Committers []string

	// The label needed to override absence from whitelist.
	WhitelistOverride string

	// If true, don't make any mutating API calls
	DryRun                 bool
	DontRequireE2ELabel    string
	E2EStatusContext       string
	RequiredStatusContexts []string
	// contains filtered or unexported fields
}

func (*FilterConfig) RefreshWhitelist

func (config *FilterConfig) RefreshWhitelist(client *github.Client, user, project string) util.StringSet

RefreshWhitelist updates the whitelist, re-getting the list of committers.

type PRFunction

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

type RateLimitRoundTripper

type RateLimitRoundTripper struct {
	// contains filtered or unexported fields
}

func (*RateLimitRoundTripper) RoundTrip

func (r *RateLimitRoundTripper) RoundTrip(req *http.Request) (resp *http.Response, err error)

Jump to

Keyboard shortcuts

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