Documentation
¶
Overview ¶
Package pulls keeps every repository's open pull requests and says for each whose turn it is (design/pulls.md, P-68).
Index ¶
- Constants
- Variables
- func Badge(e *snapshot.RepoEntry) (open, review int)
- func Counts(refs []Ref, by By) oapi.PullCounts
- func Dashboard(s *snapshot.Snapshot, d *oapi.Dashboard)
- func Feeds() snapshot.Indexer
- func Open(e *snapshot.RepoEntry) int
- func PullOf(r Ref) oapi.PullRequest
- func Repo(_ *snapshot.Snapshot, e *snapshot.RepoEntry, r *oapi.Repo)
- func Waiting(e *snapshot.RepoEntry, old time.Duration, now time.Time) (review time.Duration, stale int)
- type API
- type By
- type Detail
- type Fetcher
- type Label
- type Listed
- type Options
- type Pull
- type Pulls
- type REST
- type Ref
- type Set
- type State
- type Stats
Constants ¶
const ( // ConfirmAfter is when a run caused by an event reads again: GitHub's listing can be a few seconds behind the event. ConfirmAfter = 30 * time.Second )
const Kind = "pulls"
Kind is the job kind that reads a repository's open pull requests.
Variables ¶
var Events = []sync.Event{sync.EventPush, sync.EventOpen, "pull_request", "pull_request_review"} //nolint:gochecknoglobals // a constant list
Events are the webhook deliveries that re-read a repository's pull requests (webhook.Normalise passes them by their names). Not check_suite or status: they fire on every CI update of every commit; running checks are asked again on their own steps.
var States = []State{StateDraft, StateConflicts, StateFailing, StateChanges, StateReview, StateChecks, StateReady, StateUnknown} //nolint:gochecknoglobals // a constant list
States are the states in the order whose turn is told.
Functions ¶
func Badge ¶
Badge is a repository's open pull requests and how many wait for a review (open -1 when not read yet), for its badge.
func Counts ¶
func Counts(refs []Ref, by By) oapi.PullCounts
Counts are the open pull requests of refs that by keeps.
func Dashboard ¶
Dashboard adds the open pull requests of the fleet and of each group, of the work that counts.
func Waiting ¶
func Waiting(e *snapshot.RepoEntry, old time.Duration, now time.Time) (review time.Duration, stale int)
Waiting is what a repository's health reads of its pull requests: how long the person's pull request that waits longest for a review has been idle, and how many of automation's are older than old.
Types ¶
type API ¶
type API struct {
Current func(context.Context) *snapshot.Snapshot // the viewer's view
Off bool // switched off (features.pulls): every request is answered 404
}
API serves the open pull requests from the current snapshot. It implements the pulls method of the strict server.
func (API) ListPulls ¶
func (a API) ListPulls(ctx context.Context, req oapi.ListPullsRequestObject) (oapi.ListPullsResponseObject, error)
type Detail ¶
type Detail struct {
Review string // APPROVED, CHANGES_REQUESTED, REVIEW_REQUIRED, or empty when no review is required
Approved bool // a reviewer's latest opinion approves
Changes bool // a reviewer's latest opinion asks for changes
Checks string // the head commit's rollup: SUCCESS, FAILURE, ERROR, PENDING, EXPECTED, or empty for none
Mergeable string // MERGEABLE, CONFLICTING, UNKNOWN
Stats Stats
}
Detail is what GraphQL adds to a pull request: its review decision, the reviews that hold an opinion, its checks, whether it merges and its diff stats.
type Fetcher ¶
type Fetcher interface {
// Open lists the first 100 open pull requests, the most recently updated first.
Open(ctx context.Context, owner, name string) ([]Listed, error)
// Details asks at most maxAsk pull requests by number, and the total of open pull requests when total is set (-1 otherwise).
Details(ctx context.Context, owner, name string, numbers []int, total bool) (map[int]Detail, int, error)
}
Fetcher reads a repository's open pull requests.
type Listed ¶
type Listed struct {
Number int
Title, URL, Author string
AuthorBot bool // the author's account type is Bot
Draft, Fork bool
Created, Updated time.Time
Base, Head, HeadSHA string
Labels []Label
Requested int // reviewers and teams asked
Reviewers []string
// contains filtered or unexported fields
}
Listed is an open pull request as GitHub's REST listing gives it.
type Options ¶
type Options struct {
// Repo is the catalogued repository at a key: an archived one is read once.
Repo func(snapshot.RepoKey) (snapshot.Repo, bool)
Now func() time.Time
}
Options are what the job reads of the catalogue.
type Pull ¶
type Pull struct {
Number int `json:"n"`
Title string `json:"title"`
URL string `json:"url"`
Author string `json:"author"`
Bot bool `json:"bot,omitempty"`
Draft bool `json:"draft,omitempty"`
Fork bool `json:"fork,omitempty"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Base string `json:"base"`
Head string `json:"head"`
HeadSHA string `json:"sha"`
Labels []Label `json:"labels,omitempty"`
Requested int `json:"requested,omitempty"`
Reviewers []string `json:"reviewers,omitempty"` // the first maxReviewers people asked, by login (teams are only counted)
Review string `json:"review,omitempty"`
Approved bool `json:"approved,omitempty"`
Changes bool `json:"changes,omitempty"`
Checks string `json:"checks,omitempty"`
Mergeable string `json:"mergeable,omitempty"`
Stats *Stats `json:"stats,omitempty"`
Asked time.Time `json:"asked,omitzero"`
}
Pull is an open pull request: the REST listing's fields, and GraphQL's from when it was asked (Asked zero: never).
type Pulls ¶
type Pulls struct {
// contains filtered or unexported fields
}
Pulls is the pull requests feature.
type REST ¶
type REST interface {
REST(ctx context.Context, owner, name string) (*gh.Client, error)
GraphQLURL() string
}
REST is a source's GitHub API client per owner and its GraphQL endpoint; *github.Source implements it.
type Ref ¶
Ref is an open pull request of a repository with its state.
type Set ¶
type Set struct {
Total int `json:"total"` // open on GitHub: len(Pulls) unless there are more than 100
Pulls []Pull `json:"pulls"`
Full time.Time `json:"full,omitzero"` // when every pull request was last asked
Pending int `json:"pending,omitempty"` // the step of pendingSteps the waiting ones are at
PendingAt time.Time `json:"pendingAt,omitzero"` // when the waiting ones were last asked
}
Set is a repository's open pull requests, the most recently updated first.
type State ¶
type State string
State is whose turn a pull request is, the first that holds.
const ( StateDraft State = "draft" // the author: still a draft StateConflicts State = "conflicts" // the author: it does not merge StateFailing State = "failing" // the author: its checks fail StateChanges State = "changes" // the author: a reviewer asked for changes StateReview State = "review" // reviewers: a review is required, or none approved yet StateChecks State = "checks" // CI: its checks run StateReady State = "ready" // a maintainer: approved or no review required, checks pass StateUnknown State = "unknown" // not asked yet )