trail

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package trail provides types and helpers for managing trail metadata. Trails are branch-centric work-tracking abstractions served by the core API. They answer "why/what" (human intent) while checkpoints answer "how/when" (machine snapshots).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HumanizeBranchName

func HumanizeBranchName(branch string) string

HumanizeBranchName converts a branch name into a human-readable title. It strips common prefixes (feature/, fix/, etc.), replaces dashes/underscores with spaces, and capitalizes the first word.

Types

type Author added in v0.6.0

type Author struct {
	ID    string  `json:"id"`
	Login *string `json:"login"`
}

Author identifies the user who created a trail. On the wire the whole object may be null when the original author can no longer be resolved (e.g. the GitHub user no longer exists), and login may independently be null while the id is retained.

type ID

type ID string

ID is a 12-character hex identifier for trails.

const EmptyID ID = ""

EmptyID represents an unset or invalid trail ID.

func (ID) IsEmpty

func (id ID) IsEmpty() bool

IsEmpty returns true if the trail ID is empty or unset.

func (ID) String

func (id ID) String() string

String returns the trail ID as a string.

type Metadata

type Metadata struct {
	Number    int        `json:"number,omitempty"`
	TrailID   ID         `json:"trail_id"`
	URL       string     `json:"url,omitempty"`
	Branch    string     `json:"branch"`
	Base      string     `json:"base"`
	Title     string     `json:"title"`
	Body      string     `json:"body"`
	Status    Status     `json:"status"`
	Phase     string     `json:"phase,omitempty"`
	Author    *Author    `json:"author"`
	Assignees []string   `json:"assignees"`
	Labels    []string   `json:"labels"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	MergedAt  *time.Time `json:"merged_at"`
}

Metadata represents the metadata for a trail, matching the web PR format.

func (*Metadata) AuthorLogin added in v0.6.0

func (m *Metadata) AuthorLogin() string

AuthorLogin returns the trail author's login, or an empty string if the author is unknown (object null) or the login is null.

type Reviewer

type Reviewer struct {
	Login  string         `json:"login"`
	Status ReviewerStatus `json:"status"`
}

Reviewer represents a reviewer assigned to a trail.

type ReviewerStatus

type ReviewerStatus string

ReviewerStatus represents the review status for a reviewer.

const (
	ReviewerPending          ReviewerStatus = "pending"
	ReviewerApproved         ReviewerStatus = "approved"
	ReviewerChangesRequested ReviewerStatus = "changes_requested"
)

type Status

type Status string

Status represents the lifecycle status of a trail.

const (
	StatusDraft  Status = "draft"
	StatusOpen   Status = "open"
	StatusMerged Status = "merged"
	StatusClosed Status = "closed"
)

The status set mirrors the server's repo_trails check constraint ('draft', 'open', 'merged', 'closed'). The former in_progress and in_review statuses were folded into open server-side.

func ValidStatuses

func ValidStatuses() []Status

ValidStatuses returns all valid trail statuses in lifecycle order.

func (Status) IsValid

func (s Status) IsValid() bool

IsValid returns true if the status is a recognized trail status.

Jump to

Keyboard shortcuts

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