Documentation
¶
Overview ¶
Package tracker manages projects and tickets held in one GitHub repository.
Index ¶
- Constants
- Variables
- type BoardAccessError
- type Client
- func (c *Client) AddAttachments(ctx context.Context, number int, files []string) error
- func (c *Client) AddComment(ctx context.Context, number int, body string) error
- func (c *Client) AddLabels(ctx context.Context, number int, labels []string) error
- func (c *Client) AddProject(ctx context.Context, repo Repo) (Project, error)
- func (c *Client) ClaimNext(ctx context.Context, project string) (Ticket, bool, error)
- func (c *Client) ClaimTicket(ctx context.Context, number int) (Ticket, error)
- func (c *Client) CloseParent(ctx context.Context, number int) (bool, error)
- func (c *Client) CloseTicket(ctx context.Context, number int, opts CloseOptions) error
- func (c *Client) CreateTicket(ctx context.Context, opts CreateOptions) (Ticket, error)
- func (c *Client) CurrentProject(ctx context.Context, refresh bool) (Project, bool, error)
- func (c *Client) EditTicket(ctx context.Context, number int, opts EditOptions) error
- func (c *Client) ImportIssues(ctx context.Context, opts ImportOptions) (ImportResult, error)
- func (c *Client) InspectTicket(ctx context.Context, number int) (TicketDetail, error)
- func (c *Client) ListSubIssues(ctx context.Context, number int) ([]SubIssue, error)
- func (c *Client) ListTickets(ctx context.Context, opts ListOptions) ([]Ticket, int, error)
- func (c *Client) MoveTicket(ctx context.Context, number int, target string) error
- func (c *Client) ProjectSummary(ctx context.Context, project Project) (ProjectSummary, error)
- func (c *Client) Projects(ctx context.Context) ([]Project, error)
- func (c *Client) PullAttachments(ctx context.Context, number int, dir string) ([]string, error)
- func (c *Client) ReleaseTicket(ctx context.Context, number int) error
- func (c *Client) RemoveLabels(ctx context.Context, number int, labels []string) error
- func (c *Client) RemoveProject(ctx context.Context, name string) error
- func (c *Client) ReopenTicket(ctx context.Context, number int) error
- func (c *Client) Repo() Repo
- func (c *Client) ResolveProject(ctx context.Context, name string) (Project, error)
- func (c *Client) ScanRepos(ctx context.Context, authors []string) ([]RepoScan, error)
- func (c *Client) SetBlockers(ctx context.Context, number int, blockers []int, add bool) error
- func (c *Client) SetStatus(ctx context.Context, number int, status string) error
- func (c *Client) SetSubIssues(ctx context.Context, parent int, children []int, add bool) error
- type CloseOptions
- type Comment
- type CreateOptions
- type EditOptions
- type ImportOptions
- type ImportResult
- type ListOptions
- type Options
- type Project
- type ProjectSummary
- type Repo
- type RepoScan
- type SubIssue
- type Ticket
- type TicketDetail
Constants ¶
const ( ReasonCompleted = "completed" ReasonNotPlanned = "not-planned" ReasonDuplicate = "duplicate" )
CloseReason values for closing a ticket without a pull request.
const ( StatusTodo = "Todo" StatusDoing = "Doing" StatusDone = "Done" )
Ticket statuses, which are the columns of every project board.
const StateClosed = "CLOSED"
StateClosed is GitHub's state of a closed ticket.
Variables ¶
var ErrAlreadyClaimed = errors.New("ticket is already claimed")
ErrAlreadyClaimed reports that another agent holds the claim.
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 BoardAccessError ¶ added in v1.2.0
type BoardAccessError struct {
Detail string
}
BoardAccessError reports a GitHub login without the project scope. Its message names the fix; Detail holds GitHub's own explanation for agents.
func (*BoardAccessError) Error ¶ added in v1.2.0
func (e *BoardAccessError) Error() string
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the tracker repository.
func New ¶
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 ¶
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 ¶
AddComment adds a comment to a ticket.
func (*Client) AddLabels ¶
AddLabels adds labels to a ticket. GitHub creates a name it does not know yet.
func (*Client) AddProject ¶
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 ¶
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 ¶
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) CloseParent ¶ added in v1.2.0
CloseParent closes a parent as completed and reports whether it did. The list that found the parent can be out of date, so this decides from a fresh read.
func (*Client) CloseTicket ¶
CloseTicket closes a ticket after confirming every pull request merged.
func (*Client) CreateTicket ¶
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 ¶
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 ¶
EditTicket changes a ticket's title or body.
func (*Client) ImportIssues ¶ added in v1.1.0
func (c *Client) ImportIssues(ctx context.Context, opts ImportOptions) (ImportResult, error)
ImportIssues transfers a repository's movable issues into the tracker. A public issue cannot move back, so the tracker must be private, and only issues written entirely by trusted authors move.
func (*Client) InspectTicket ¶
InspectTicket reads a ticket with everything an agent needs to work on it.
func (*Client) ListSubIssues ¶ added in v1.2.0
ListSubIssues returns a ticket's sub-issues.
func (*Client) ListTickets ¶
ListTickets returns matching tickets, oldest first, and how many tickets match in all, which exceeds the tickets returned when Limit cuts the list. GitHub counts what it filters on the first page. A client-side filter has no such count, so it reads every page whatever the limit.
func (*Client) MoveTicket ¶
MoveTicket reassigns a ticket to another project and keeps its status.
func (*Client) ProjectSummary ¶
ProjectSummary counts a project's tickets.
func (*Client) PullAttachments ¶
PullAttachments downloads a ticket's attachments into dir and returns their paths.
func (*Client) ReleaseTicket ¶
ReleaseTicket gives up a claim and returns the ticket to Todo.
func (*Client) RemoveLabels ¶
RemoveLabels removes labels from a ticket, one request per label.
func (*Client) RemoveProject ¶
RemoveProject unregisters a project with no open tickets. It deletes the board and clears the label's repository, so closed tickets keep their label. Closed tickets that were only on the board get the label first, or they would lose their project with it.
func (*Client) ReopenTicket ¶
ReopenTicket reopens a closed ticket with status Todo.
func (*Client) ResolveProject ¶
ResolveProject looks up a registered project by name.
func (*Client) ScanRepos ¶ added in v1.1.0
ScanRepos reports every unarchived, non-fork repository of the tracker's owner with open issues. The owner's text is always trusted; authors adds more logins.
func (*Client) SetBlockers ¶
SetRelations adds or removes blockers of a ticket.
type CloseOptions ¶
CloseOptions gives the evidence for closing a ticket: merged pull requests, a pull request whose head landed without GitHub marking it merged, or a reason.
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 ¶
EditOptions holds ticket fields to change. Nil fields stay unchanged.
type ImportOptions ¶ added in v1.1.0
type ImportOptions struct {
Repo Repo
Authors []string
DryRun bool
Limit int
// OnMove reports each transfer as it finishes, because a run can take an hour.
OnMove func(source, ticket int) error
}
ImportOptions describes moving a repository's open issues into the tracker.
type ImportResult ¶ added in v1.1.0
ImportResult counts a run. Remaining is what a later run would still move.
type ListOptions ¶
type ListOptions struct {
Project string
State string
Status string
Label string
Search string
Ready bool
Closable 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.
type ProjectSummary ¶
ProjectSummary describes a project and its ticket counts.
type Repo ¶
Repo identifies a GitHub repository.
func CurrentRepo ¶
CurrentRepo returns the working directory's GitHub repository.
type RepoScan ¶ added in v1.1.0
RepoScan counts one repository's open issues by who wrote them. It holds no issue text, because public issues are untrusted input. Others counts issues with text from anyone untrusted, including in a private repository where they can move.
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
SubIssues int
OpenSubIssues int
Activity time.Time
// contains filtered or unexported fields
}
Ticket is one issue in the tracker.
func (Ticket) Closable ¶ added in v1.2.0
Closable reports an open parent whose sub-issues are all closed. A claimed parent stays open, because closing it would take the ticket from whoever holds it, and so does a blocked one, because something still has to happen first.
func (Ticket) Ready ¶
Ready reports whether a ticket can be picked up: open, unblocked, with no blocked ancestor and no open sub-issues, and not in progress. A parent waits for its children, so the work gets claimed rather than its container. The blocked label covers waits with no ticket to name, such as a person's input.