issue

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 8 Imported by: 0

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

View Source
const (
	StateOpen   = "open"
	StateClosed = "closed"

	ReasonCompleted  = "completed"
	ReasonNotPlanned = "not_planned"
)

Variables

Statuses lists statuses in workflow order.

Functions

func QueryKeys

func QueryKeys() []string

QueryKeys lists the qualifiers ParseQuery understands, for help text.

func WithLabels

func WithLabels(labels, add, remove []string) []string

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.

func (Change) Apply

func (ch Change) Apply(i Issue) Issue

Apply returns i with ch applied, as GitHub would after the change.

func (Change) Empty

func (ch Change) Empty() bool

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

func FromGitHub(repo string, src gh.Issue) Issue

FromGitHub converts a REST API issue.

func (Issue) HasLabel

func (i Issue) HasLabel(name string) bool

func (Issue) IsAssigned

func (i Issue) IsAssigned(login string) bool

func (Issue) IsOpen

func (i Issue) IsOpen() bool

func (Issue) Key

func (i Issue) Key() string

Key identifies an issue across repos, including issues that haven't been created on GitHub yet.

func (Issue) Ref

func (i Issue) Ref() string

Ref is the short human reference, e.g. "triage#12".

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

func ParseQuery(raw string) Query

ParseQuery parses a filter. Unknown qualifiers are treated as text so that typing "foo:bar" still finds issues containing it.

func (Query) And

func (q Query) And(other Query) Query

And returns a query matching both q and other.

func (Query) Empty

func (q Query) Empty() bool

func (Query) Has

func (q Query) Has(key string) bool

Has reports whether the query contains a qualifier with key, such as "is".

func (Query) Match

func (q Query) Match(i Issue, ctx MatchContext) bool

Match reports whether i satisfies every term.

func (Query) String

func (q Query) String() string

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".

func (Query) Without

func (q Query) Without(key string) Query

Without returns q minus every term using qualifier key.

type Status

type Status int

Status is where an issue is in its life.

const (
	StatusTodo Status = iota
	StatusIdea
	StatusInProgress
	StatusBlocked
	StatusDone
	StatusWontDo
)

func (Status) String

func (s Status) String() string

type Type

type Type int

Type is what kind of work an issue is.

const (
	TypeTask Type = iota
	TypeBug
	TypeFeature
	TypeDocs
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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