Documentation
¶
Index ¶
- Constants
- func BranchFieldOrEmpty(b *BranchRow, fn func(*BranchRow) string) string
- func TrackerStatusOrNA(s *string) string
- type Branch
- type BranchRow
- type BranchStatus
- type CommandHistoryRow
- type Issue
- type IssueRow
- type ReviewRow
- type ReviewStatus
- type Store
- func (s *Store) ChildrenAllMerged(ctx context.Context, parentSlug string) (bool, error)
- func (s *Store) Close() error
- func (s *Store) DeleteBranch(ctx context.Context, name string) error
- func (s *Store) GetLatestReview(ctx context.Context, issueSlug string) (*ReviewRow, error)
- func (s *Store) GetParentIssue(ctx context.Context, childSlug string) (string, error)
- func (s *Store) InsertCommandHistory(ctx context.Context, command string, payload any) error
- func (s *Store) InsertIssueRelation(ctx context.Context, parentSlug, childSlug string) error
- func (s *Store) InsertIssueWithBranch(ctx context.Context, issue *Issue, branch *Branch) error
- func (s *Store) InsertReview(ctx context.Context, issueSlug, reviewer string) (*ReviewRow, error)
- func (s *Store) ListBranches(ctx context.Context, status BranchStatus) ([]BranchRow, error)
- func (s *Store) ListBranchesByIssueSlugs(ctx context.Context, slugs []string) (map[string]BranchRow, error)
- func (s *Store) ListChildIssues(ctx context.Context, parentSlug string) ([]string, error)
- func (s *Store) ListCommandHistory(ctx context.Context, command string, limit int) ([]CommandHistoryRow, error)
- func (s *Store) ListReviews(ctx context.Context, issueSlug string) ([]ReviewRow, error)
- func (s *Store) SetReviewRound(ctx context.Context, id int64, round int) error
- func (s *Store) UpdateBranchStatus(ctx context.Context, name string, statusID int64, mergedAt *time.Time) error
- func (s *Store) UpdateIssueStatus(ctx context.Context, issueID, statusID int64) error
- func (s *Store) UpdateReviewStatus(ctx context.Context, id int64, status ReviewStatus, hasCommits bool) error
- func (s *Store) UpdateReviewerIdentity(ctx context.Context, id int64, reviewer string) error
Constants ¶
const ( StatusIDInProgress int64 = 1 StatusIDMerged int64 = 2 StatusIDClosed int64 = 3 )
StatusID* constants are the integer primary keys for the seeded rows in the statuses table (see migrations/).
Variables ¶
This section is empty.
Functions ¶
func BranchFieldOrEmpty ¶ added in v0.7.2
BranchFieldOrEmpty returns fn(b) or "∅" when b is nil.
func TrackerStatusOrNA ¶ added in v0.7.2
TrackerStatusOrNA returns *s or "N.A." when s is nil.
Types ¶
type Branch ¶
type Branch struct {
Name string
IssueID int64
Type string
StatusID int64
CreatedAt time.Time
MergedAt *time.Time
}
Branch represents a tracked branch record. The branch's full git ref name is its primary key.
type BranchRow ¶
type BranchRow struct {
IssueID int64 `json:"issue_id"`
IssueSlug string `json:"issue_slug"`
Title string `json:"title"`
BranchName string `json:"branch_name"`
Type string `json:"type"`
Status BranchStatus `json:"status"`
CreatedAt time.Time `json:"created_at"`
}
BranchRow is the joined result of one branch with its parent issue and status.
type BranchStatus ¶
type BranchStatus string
BranchStatus is the typed string representation of the statuses table.
const ( BranchStatusInProgress BranchStatus = "in_progress" BranchStatusMerged BranchStatus = "merged" BranchStatusClosed BranchStatus = "closed" BranchStatusAll BranchStatus = "" // sentinel: no WHERE filter; not a DB value )
type CommandHistoryRow ¶ added in v0.8.0
type CommandHistoryRow struct {
ID int64
Payload json.RawMessage // raw JSON; caller unmarshals into the shape they need
CreatedAt time.Time
}
CommandHistoryRow is one row from the command_history table.
type Issue ¶
type Issue struct {
ID int64
// tracker string ID: "ABC-42", "42", …
IDSlug string
Title string
StatusID int64
TrackerType *string // nil = manual entry; non-nil = tracker type (e.g. "redmine")
}
Issue is the SQLite persistence row for a work item — the durable record written once a branch exists. It is the last of three "Issue" shapes: a tracker.Issue (wire shape) becomes an issue.Issue (in-flow entity) and is finally persisted here. Unlike those, this carries a synthesised int64 PK, a normalised StatusID foreign key (not a status string), and a nil-able TrackerType to mark manual entries. See the doc on issue.Issue for the end-to-end flow.
type IssueRow ¶ added in v0.3.0
type IssueRow struct {
IssueSlug string `json:"issue_slug"`
Title string `json:"title"`
Project string `json:"project"` // tracker project / repo; empty when unknown
TrackerStatus *string `json:"tracker_status"` // nil → display "N.A."
Branch *BranchRow `json:"branch"` // nil → not started locally
}
IssueRow is the unified display row for git zf issue list. It composes an issue identity with an optional local branch.
type ReviewRow ¶ added in v0.11.0
type ReviewRow struct {
ID int64
IssueSlug string
Round int
Reviewer string
Status ReviewStatus
HasCommits bool
CreatedAt time.Time
ResolvedAt *time.Time
}
ReviewRow is one round of review from the reviews table.
type ReviewStatus ¶ added in v0.11.0
type ReviewStatus string
ReviewStatus is the typed status of a review round in the reviews table.
const ( ReviewStatusInReview ReviewStatus = "in_review" ReviewStatusApproved ReviewStatus = "approved" ReviewStatusChangesRequested ReviewStatus = "changes_requested" )
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store wraps a SQLite database for branch and issue persistence.
func Open ¶
Open opens (or creates) the SQLite database at dir/[dbName] and runs pending migrations.
func OpenRepo ¶ added in v0.7.2
OpenRepo opens the local store inside the current git repository's .git directory. Resolves the real git dir via git.Client.GitDir() so it works in regular repos, submodules (where <worktree>/.git is a gitlink file), and linked worktrees alike.
func (*Store) ChildrenAllMerged ¶ added in v0.11.0
ChildrenAllMerged reports whether every branch of every child issue of parentSlug has BranchStatusMerged. A child with no branches (not yet started) is treated as not merged. Returns true when parentSlug has no children.
Uses a COUNT query per child to handle issues with multiple branches (e.g. created with --variant): all branches must be merged, not just one.
func (*Store) DeleteBranch ¶
DeleteBranch removes the branch record identified by name.
func (*Store) GetLatestReview ¶ added in v0.11.0
GetLatestReview returns the most recent review row for issueSlug, or nil if none.
func (*Store) GetParentIssue ¶ added in v0.11.0
GetParentIssue returns the parent issue slug for childSlug, or "" if it has no parent.
func (*Store) InsertCommandHistory ¶ added in v0.8.0
InsertCommandHistory records one completed form submission. payload is marshalled to JSON internally; it must be JSON-serialisable.
func (*Store) InsertIssueRelation ¶ added in v0.11.0
InsertIssueRelation records a parent-child relationship between two issue slugs. Silently succeeds if the relation already exists (idempotent).
func (*Store) InsertIssueWithBranch ¶
InsertIssueWithBranch inserts an issue and its linked branch in a single transaction.
func (*Store) InsertReview ¶ added in v0.11.0
InsertReview opens a new review round for issueSlug. The round number is one greater than the highest existing round for that slug (or 1 if none). The SELECT MAX + INSERT is wrapped in a transaction so the round counter is incremented atomically.
func (*Store) ListBranches ¶
ListBranches returns all branches joined with their issue and status, ordered by created_at DESC. BranchStatusAll returns every row.
func (*Store) ListBranchesByIssueSlugs ¶ added in v0.3.0
func (s *Store) ListBranchesByIssueSlugs(ctx context.Context, slugs []string) (map[string]BranchRow, error)
ListBranchesByIssueSlugs returns a map[id_slug]BranchRow for the given slugs. Uses a single SELECT … WHERE i.id_slug IN (…). Returns an empty map for empty input.
func (*Store) ListChildIssues ¶ added in v0.11.0
ListChildIssues returns the slugs of all direct children of parentSlug.
func (*Store) ListCommandHistory ¶ added in v0.8.0
func (s *Store) ListCommandHistory(ctx context.Context, command string, limit int) ([]CommandHistoryRow, error)
ListCommandHistory returns the most recent limit entries for command, newest-first.
func (*Store) ListReviews ¶ added in v0.11.0
ListReviews returns all review rounds for issueSlug, newest first.
func (*Store) SetReviewRound ¶ added in v0.11.1
SetReviewRound updates the round field for a specific review record. Used by ensureReviewRecord to sync the round when the store is empty but the ref is at a later round (cross-machine fresh-clone scenario).
func (*Store) UpdateBranchStatus ¶
func (s *Store) UpdateBranchStatus(ctx context.Context, name string, statusID int64, mergedAt *time.Time) error
UpdateBranchStatus updates a branch's status. mergedAt must be non-nil when statusID == 2 (merged); the enforce_merged_at trigger rejects nil.
func (*Store) UpdateIssueStatus ¶
UpdateIssueStatus updates an issue's status.
func (*Store) UpdateReviewStatus ¶ added in v0.11.0
func (s *Store) UpdateReviewStatus(ctx context.Context, id int64, status ReviewStatus, hasCommits bool) error
UpdateReviewStatus sets the status, has_commits, and resolved_at of an existing review row.