Documentation
¶
Overview ¶
Package issue holds triage's view of a GitHub issue and the label conventions that give issues a type and a status.
Index ¶
- Constants
- Variables
- func QueryKeys() []string
- func WithLabels(labels, add, remove []string) []string
- type Change
- type Convention
- func (c Convention) IsConventionLabel(label string) bool
- func (c Convention) LabelColor(label string) string
- func (c Convention) LabelDescription(label string) string
- func (c Convention) ParseStatus(value string) (Status, error)
- func (c Convention) ParseType(value string) (Type, error)
- func (c Convention) SetStatus(i Issue, s Status) Change
- func (c Convention) SetType(i Issue, t Type) Change
- func (c Convention) StatusLabel(s Status) string
- func (c Convention) StatusOf(i Issue) Status
- func (c Convention) TypeLabel(t Type) string
- func (c Convention) TypeOf(i Issue) Type
- func (c Convention) WithDefaults() Convention
- type Issue
- type MatchContext
- type Query
- type Status
- type Type
Constants ¶
const ( StateOpen = "open" StateClosed = "closed" ReasonCompleted = "completed" ReasonNotPlanned = "not_planned" )
Variables ¶
var Statuses = []Status{StatusIdea, StatusTodo, StatusInProgress, StatusBlocked, StatusDone, StatusWontDo}
Statuses lists statuses in workflow order.
var Types = []Type{TypeTask, TypeBug, TypeFeature, TypeDocs}
Functions ¶
func QueryKeys ¶
func QueryKeys() []string
QueryKeys lists the qualifiers ParseQuery understands, for help text.
func WithLabels ¶
WithLabels returns labels with add appended and remove dropped, compared case-insensitively and without duplicates.
Types ¶
type Change ¶
type Change struct {
AddLabels []string
RemoveLabels []string
// State is "open" or "closed" when the state must change, else "".
State string
StateReason string
}
Change is the set of edits that moves an issue to a new type or status.
type Convention ¶
type Convention struct {
Bug string `toml:"bug"`
Feature string `toml:"feature"`
Docs string `toml:"docs"`
Idea string `toml:"idea"`
InProgress string `toml:"in_progress"`
Blocked string `toml:"blocked"`
}
Convention maps types and statuses to label names. The defaults reuse the labels GitHub creates in every new repository where possible.
func DefaultConvention ¶
func DefaultConvention() Convention
func (Convention) IsConventionLabel ¶
func (c Convention) IsConventionLabel(label string) bool
IsConventionLabel reports whether label carries a type or status.
func (Convention) LabelColor ¶
func (c Convention) LabelColor(label string) string
LabelColor returns a stable hex color (without '#') for a label triage creates.
func (Convention) LabelDescription ¶
func (c Convention) LabelDescription(label string) string
LabelDescription is the description triage gives labels it creates.
func (Convention) ParseStatus ¶
func (c Convention) ParseStatus(value string) (Status, error)
ParseStatus accepts names like "idea", "in progress", "in-progress", "wontdo" or "done".
func (Convention) ParseType ¶
func (c Convention) ParseType(value string) (Type, error)
ParseType accepts names like "bug", "Feature", "docs" or the convention's label names.
func (Convention) SetStatus ¶
func (c Convention) SetStatus(i Issue, s Status) Change
SetStatus returns the edits that give i status s: at most one status label on open issues, none on closed ones, and the matching close reason.
func (Convention) SetType ¶
func (c Convention) SetType(i Issue, t Type) Change
SetType returns the label edits that give i type t.
func (Convention) StatusLabel ¶
func (c Convention) StatusLabel(s Status) string
StatusLabel returns the label for s, or "" when the status is expressed by the issue's state alone.
func (Convention) StatusOf ¶
func (c Convention) StatusOf(i Issue) Status
StatusOf derives an issue's status from its state and labels.
func (Convention) TypeLabel ¶
func (c Convention) TypeLabel(t Type) string
TypeLabel returns the label for t, or "" for TypeTask.
func (Convention) TypeOf ¶
func (c Convention) TypeOf(i Issue) Type
TypeOf derives an issue's type from its labels. "feature" counts as a feature even when the convention uses "enhancement".
func (Convention) WithDefaults ¶
func (c Convention) WithDefaults() Convention
WithDefaults fills empty fields from DefaultConvention.
type Issue ¶
type Issue struct {
Repo string `json:"repo"`
Number int `json:"number,omitempty"`
LocalID string `json:"local_id,omitempty"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"`
StateReason string `json:"state_reason,omitempty"`
Labels []string `json:"labels,omitempty"`
Assignees []string `json:"assignees,omitempty"`
Author string `json:"author,omitempty"`
Comments int `json:"comments,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ClosedAt time.Time `json:"closed_at,omitempty"`
URL string `json:"url,omitempty"`
}
Issue is a GitHub issue as triage displays it.
func FromGitHub ¶
FromGitHub converts a REST API issue.
func (Issue) IsAssigned ¶
type MatchContext ¶
type MatchContext struct {
Me string
Convention Convention
}
MatchContext supplies what a query needs besides the issue itself.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query is a parsed filter such as
is:open repo:triage label:bug assignee:@me status:"in progress" crash
Qualifiers can be negated with a leading "-". Bare words match the title, body, or issue number.
func ParseQuery ¶
ParseQuery parses a filter. Unknown qualifiers are treated as text so that typing "foo:bar" still finds issues containing it.
func (Query) Match ¶
func (q Query) Match(i Issue, ctx MatchContext) bool
Match reports whether i satisfies every term.
func (Query) Validate ¶
func (q Query) Validate(conv Convention) error
Validate returns an error describing the first qualifier value that can never match, such as "type:nope".