tracker

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 13 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 reads and updates tickets in the trackers teams use besides GitHub issues — Linear and Jira Cloud — so a task can start from one and its branch and pull request can be linked back to it. Each is reached over its own HTTP API with a personal key; nothing here runs a program or keeps state.

Index

Constants

View Source
const (
	LinearKeyEnv = "LINEAR_API_KEY"
	JiraTokenEnv = "JIRA_API_TOKEN"
)

The variables a key is read from when config.toml names none.

View Source
const (
	Linear = "linear"
	Jira   = "jira"
)

Trackers conch has code for.

View Source
const LinearAPI = "https://api.linear.app/graphql"

LinearAPI is Linear's GraphQL endpoint.

Variables

View Source
var ErrNotFound = errors.New("no such ticket")

ErrNotFound is a ticket the tracker has not got, or will not show.

View Source
var Names = []string{Linear, Jira}

Names are the trackers, in the order a choice between them is offered.

Functions

func CheckRef

func CheckRef(ref string) (tracker, key string, err error)

CheckRef is ParseRef for a command that hands the ticket to a server which may know more trackers than conch has code for: a tickets integration's NAME:KEY (shortcut:123), or a key alone (123) for a project tied to one, is taken as given and left to the server to make sense of. What is no ticket of anybody's is still refused here.

func Choose

func Choose(cfg config.TrackersCfg, project, root, ref string, look Lookup) (name, scope string, err error)

Choose says which tracker a project's tickets come from, and the team or project in it: what ref names (linear:ENG-1, an address), else the project's [[trackers.projects]] entry, else the one tracker set up. ref may be "" when listing.

func Configured

func Configured(cfg config.TrackersCfg, look Lookup) []string

Configured are the trackers cfg has enough of to reach: a key for Linear, a site for Jira (whose email and token are asked for when it is opened, so a half-set Jira says what it lacks rather than vanishing).

func KeyFrom

func KeyFrom(name string, cfg config.TrackersCfg, inEnv func(string) bool) string

KeyFrom says where a tracker's key is read from — config.toml, a variable, or the Keychain — never the key itself. inEnv says whether a variable is set in this process's environment.

func ParseRef

func ParseRef(ref string) (tracker, key string, err error)

ParseRef reads a ticket as somebody would give it: its key (ENG-123), its key after the tracker's name (linear:ENG-123), or its address in the tracker. tracker is "" when nothing in ref says which — Linear's keys and Jira's look alike — and key is upper case.

func Scope

func Scope(cfg config.TrackersCfg, project, root, name string) string

Scope is the team or project of the tracker named whose tickets a project lists: its [[trackers.projects]] key, else the tracker's own.

func Title

func Title(name string) string

Title is the tracker's name as it calls itself.

func ValidKey

func ValidKey(key string) bool

ValidKey says whether key is shaped like a ticket's key, ENG-123.

Types

type Account

type Account struct {
	Who       string `json:"who,omitempty"`
	Email     string `json:"email,omitempty"`
	Workspace string `json:"workspace,omitempty"`
	Scopes    []Area `json:"scopes,omitempty"`
}

Account is who a tracker's key belongs to and what it can see: what Settings shows to say a key works before anything is asked of it.

type Area

type Area struct {
	Key  string `json:"key"`
	Name string `json:"name,omitempty"`
}

Area is a Linear team or a Jira project the key can see.

type Checker

type Checker interface {
	Check(ctx context.Context) (Account, error)
}

Checker is a tracker that can say whose its key is.

type Comment

type Comment struct {
	Author string `json:"author,omitempty"`
	Body   string `json:"body"`
}

Comment is one comment on a ticket.

type Link struct {
	Title string `json:"title,omitempty"`
	URL   string `json:"url"`
}

Link is a link attached to a ticket: a branch, a pull request.

type ListOptions

type ListOptions struct {
	// Scope is the Linear team's key or the Jira project's key; "" is
	// every one the key can see.
	Scope string
	// Assigned keeps only the tickets assigned to the key's own person.
	Assigned bool
	// Limit is how many, newest first; 0 is 30.
	Limit int
}

ListOptions narrow a list of tickets.

type Lookup

type Lookup func(name string) string

Lookup reads a variable's value: the environment, then wherever else the caller keeps secrets (a server on a Mac, the Keychain). "" is none.

type Ticket

type Ticket struct {
	Tracker  string    `json:"tracker"`
	Key      string    `json:"key"`
	Title    string    `json:"title"`
	Body     string    `json:"body,omitempty"`
	URL      string    `json:"url,omitempty"`
	Status   string    `json:"status,omitempty"`
	Comments []Comment `json:"comments,omitempty"`
	Links    []Link    `json:"links,omitempty"`
}

Ticket is a ticket, as much of it as a task needs.

type Tracker

type Tracker interface {
	Name() string
	// List is the open tickets, most recently changed first.
	List(ctx context.Context, opt ListOptions) ([]Ticket, error)
	// Get reads one ticket, with its comments and links.
	Get(ctx context.Context, key string) (Ticket, error)
	// Comment adds a comment.
	Comment(ctx context.Context, key, body string) error
	// SetStatus moves the ticket to the status named (In Review, Done),
	// matched without regard to case, and says the status it is now in.
	SetStatus(ctx context.Context, key, status string) (string, error)
	// Link attaches a link — a branch, a pull request — to the ticket.
	Link(ctx context.Context, key, url, title string) error
}

Tracker is one tracker conch has code for.

func NewJira

func NewJira(site, email, token string) Tracker

NewJira is the Jira Cloud site (https://acme.atlassian.net), reached as email with the token.

func NewLinear

func NewLinear(url, key string) Tracker

NewLinear is Linear at url ("" is LinearAPI) with the key.

func Open

func Open(cfg config.TrackersCfg, name string, look Lookup) (Tracker, error)

Open is the tracker named, as cfg sets it up.

Jump to

Keyboard shortcuts

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