store

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusIDInProgress int64 = 1
	StatusIDMerged     int64 = 2
)

StatusIDInProgress and StatusIDMerged are the integer primary keys for the seeded rows in the statuses table (see migrations/0001_initial.sql).

Variables

This section is empty.

Functions

This section is empty.

Types

type Branch

type Branch struct {
	UUID      string
	Name      string
	IssueID   int64
	Type      string
	StatusID  int64
	CreatedAt time.Time
	MergedAt  *time.Time
}

Branch represents a tracked branch record.

type BranchRow

type BranchRow struct {
	UUID       string       `json:"uuid"`
	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"
	BranchStatusAll        BranchStatus = "" // sentinel: no WHERE filter; not a DB value
)

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 represents a tracked issue record.

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 Store

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

Store wraps a SQLite database for branch and issue persistence.

func Open

func Open(ctx context.Context, dir string) (*Store, error)

Open opens (or creates) the SQLite database at dir/[dbName] and runs pending migrations.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database connection.

func (*Store) DeleteBranch

func (s *Store) DeleteBranch(ctx context.Context, uuid string) error

DeleteBranch removes the branch record identified by uuid.

func (*Store) InsertIssueWithBranch

func (s *Store) InsertIssueWithBranch(ctx context.Context, issue *Issue, branch *Branch) error

InsertIssueWithBranch inserts an issue and its linked branch in a single transaction.

func (*Store) ListBranches

func (s *Store) ListBranches(ctx context.Context, status BranchStatus) ([]BranchRow, error)

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) UpdateBranchStatus

func (s *Store) UpdateBranchStatus(ctx context.Context, uuid string, statusID int64, mergedAt *time.Time) error

UpdateBranchStatus updates a branch's status. mergedAt must be non-nil when statusID == 2 (merged).

func (*Store) UpdateIssueStatus

func (s *Store) UpdateIssueStatus(ctx context.Context, issueID, statusID int64) error

UpdateIssueStatus updates an issue's status.

Jump to

Keyboard shortcuts

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