tracker

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tracker manages projects and tickets held in one GitHub repository.

Index

Constants

View Source
const (
	ReasonNotPlanned = "not-planned"
	ReasonDuplicate  = "duplicate"
)

CloseReason values for closing a ticket without a pull request.

View Source
const (
	StatusTodo  = "Todo"
	StatusDoing = "Doing"
	StatusDone  = "Done"
)

Ticket statuses, which are the columns of every project board.

Variables

View Source
var ErrAlreadyClaimed = errors.New("ticket is already claimed")

ErrAlreadyClaimed reports that another agent holds the claim.

View Source
var ErrRateLimited = errors.New("GitHub rate limit reached")

ErrRateLimited reports that GitHub refused a request because of a rate limit.

Functions

This section is empty.

Types

type Client

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

Client talks to the tracker repository.

func New

func New(opts Options) (*Client, error)

New builds a Client. It leaves go-gh's response cache disabled because that cache can replay GraphQL mutations and stored 429 responses.

func (*Client) AddAttachments

func (c *Client) AddAttachments(ctx context.Context, number int, files []string) error

AddAttachments uploads files to a ticket. GitHub has no documented upload API, so this is the one operation that runs the gh binary.

func (*Client) AddComment

func (c *Client) AddComment(ctx context.Context, number int, body string) error

AddComment adds a comment to a ticket.

func (*Client) AddLabels

func (c *Client) AddLabels(ctx context.Context, number int, labels []string) error

AddLabels adds labels to a ticket. GitHub creates a name it does not know yet.

func (*Client) AddProject

func (c *Client) AddProject(ctx context.Context, repo Repo) (Project, error)

AddProject registers a code repository. Writing the label comes last, so a failed run leaves nothing registered and can simply be repeated.

func (*Client) ClaimNext

func (c *Client) ClaimNext(ctx context.Context, project string) (Ticket, bool, error)

ClaimNext claims the oldest ready ticket, moving on when another agent wins a candidate. It reports false when no ticket is ready. Project may be empty.

func (*Client) ClaimTicket

func (c *Client) ClaimTicket(ctx context.Context, number int) (Ticket, error)

ClaimTicket takes a ticket for the caller. GitHub rejects a second create of the same ref, which makes the claim atomic where labels, assignees, and project fields would accept both writers. GraphQL cannot see this namespace, so claims use REST.

func (*Client) CloseTicket

func (c *Client) CloseTicket(ctx context.Context, number int, opts CloseOptions) error

CloseTicket closes a ticket after confirming every pull request merged.

func (*Client) CreateTicket

func (c *Client) CreateTicket(ctx context.Context, opts CreateOptions) (Ticket, error)

CreateTicket creates a ticket on its project board with status Todo. A failure after creation names the ticket so the caller can finish it instead of duplicating it.

func (*Client) CurrentProject

func (c *Client) CurrentProject(ctx context.Context, refresh bool) (Project, bool, error)

CurrentProject maps the working directory's GitHub remote to a project without calling GitHub unless refresh is set and the cached metadata has no match.

func (*Client) EditTicket

func (c *Client) EditTicket(ctx context.Context, number int, opts EditOptions) error

EditTicket changes a ticket's title or body.

func (*Client) InspectTicket

func (c *Client) InspectTicket(ctx context.Context, number int) (TicketDetail, error)

InspectTicket reads a ticket with everything an agent needs to work on it.

func (*Client) ListTickets

func (c *Client) ListTickets(ctx context.Context, opts ListOptions) ([]Ticket, error)

ListTickets returns matching tickets, oldest first, in as few pages as Limit allows.

func (*Client) MoveTicket

func (c *Client) MoveTicket(ctx context.Context, number int, target string) error

MoveTicket reassigns a ticket to another project and keeps its status.

func (*Client) ProjectSummary

func (c *Client) ProjectSummary(ctx context.Context, project Project) (ProjectSummary, error)

ProjectSummary counts a project's tickets in one request.

func (*Client) Projects

func (c *Client) Projects(ctx context.Context) ([]Project, error)

Projects lists registered projects from GitHub.

func (*Client) PullAttachments

func (c *Client) PullAttachments(ctx context.Context, number int, dir string) ([]string, error)

PullAttachments downloads a ticket's attachments into dir and returns their paths.

func (*Client) ReleaseTicket

func (c *Client) ReleaseTicket(ctx context.Context, number int) error

ReleaseTicket gives up a claim and returns the ticket to Todo.

func (*Client) RemoveLabels

func (c *Client) RemoveLabels(ctx context.Context, number int, labels []string) error

RemoveLabels removes labels from a ticket, one request per label.

func (*Client) RemoveProject

func (c *Client) RemoveProject(ctx context.Context, name string) error

RemoveProject unregisters a project with no open tickets. It deletes the board and clears the label's repository, so closed tickets keep their label.

func (*Client) ReopenTicket

func (c *Client) ReopenTicket(ctx context.Context, number int) error

ReopenTicket reopens a closed ticket with status Todo.

func (*Client) Repo

func (c *Client) Repo() Repo

Repo returns the tracker repository.

func (*Client) ResolveProject

func (c *Client) ResolveProject(ctx context.Context, name string) (Project, error)

ResolveProject looks up a registered project by name.

func (*Client) SetBlockers

func (c *Client) SetBlockers(ctx context.Context, number int, blockers []int, add bool) error

SetRelations adds or removes blockers of a ticket.

func (*Client) SetStatus

func (c *Client) SetStatus(ctx context.Context, number int, status string) error

SetStatus moves an unclaimed ticket to Todo or Done. Doing belongs to claims.

func (*Client) SetSubIssues

func (c *Client) SetSubIssues(ctx context.Context, parent int, children []int, add bool) error

SetSubIssues attaches or detaches sub-issues of a parent ticket.

type CloseOptions

type CloseOptions struct {
	PRs    []string
	Reason string
}

CloseOptions gives the evidence for closing a ticket: merged pull requests, or a reason.

type Comment

type Comment struct {
	Author    string
	CreatedAt time.Time
	Body      string
}

Comment is one comment on a ticket.

type CreateOptions

type CreateOptions struct {
	Project        string
	Title          string
	Body           string
	DiscoveredFrom int
	Parent         int
	BlockedBy      []int
	Blocking       []int
	Labels         []string
	Attachments    []string
}

CreateOptions describes a new ticket.

type EditOptions

type EditOptions struct {
	Title *string
	Body  *string
}

EditOptions holds ticket fields to change. Nil fields stay unchanged.

type ListOptions

type ListOptions struct {
	Project   string
	State     string
	Status    string
	Label     string
	Search    string
	Ready     bool
	Stale     bool
	StaleDays int
	Limit     int
	Now       time.Time
}

ListOptions filters tickets. Project is empty for all projects.

type Options

type Options struct {
	Repo           Repo
	CacheDir       string
	RequirePrivate bool
	Transport      http.RoundTripper
	Token          string
}

Options configures a Client. Transport and Token exist for tests; zero values use the live GitHub configuration.

type Project

type Project struct {
	Name          string            `json:"name"`
	Repo          string            `json:"repo"`
	Public        bool              `json:"public"`
	LabelID       string            `json:"label_id"`
	BoardID       string            `json:"board_id,omitempty"`
	BoardURL      string            `json:"board_url,omitempty"`
	StatusFieldID string            `json:"status_field_id,omitempty"`
	StatusOptions map[string]string `json:"status_options,omitempty"`
}

Project is a code repository registered with the tracker.

func (Project) Label

func (p Project) Label() string

Label returns the routing label for the project.

type ProjectSummary

type ProjectSummary struct {
	Project Project
	Open    int
	Closed  int
}

ProjectSummary describes a project and its ticket counts.

type Repo

type Repo struct {
	Owner string
	Name  string
}

Repo identifies a GitHub repository.

func CurrentRepo

func CurrentRepo() (Repo, bool)

CurrentRepo returns the working directory's GitHub repository.

func ParseRepo

func ParseRepo(value string) (Repo, error)

ParseRepo reads an owner/name repository reference.

func (Repo) String

func (r Repo) String() string

type SubIssue

type SubIssue struct {
	Number int
	Title  string
	State  string
}

SubIssue is a child ticket.

type Ticket

type Ticket struct {
	ID            string
	Number        int
	Title         string
	State         string
	URL           string
	Project       string
	Labels        []string
	Status        string
	Parent        int
	Blockers      []int
	ParentBlocked bool
	Activity      time.Time
	// contains filtered or unexported fields
}

Ticket is one issue in the tracker.

func (Ticket) Ready

func (t Ticket) Ready() bool

Ready reports whether a ticket can be picked up: open, unblocked, with no blocked ancestor, and not in progress. Parents stay ready while their children are open.

func (Ticket) Stale

func (t Ticket) Stale(days int, now time.Time) bool

Stale reports a Doing ticket with no activity for the given number of days.

type TicketDetail

type TicketDetail struct {
	Ticket
	Body        string
	Comments    []Comment
	Blocking    []int
	SubIssues   []SubIssue
	Attachments []string
	PublicRepo  bool
}

TicketDetail is a ticket with its text, relations, and attachment URLs.

Jump to

Keyboard shortcuts

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