Help us shape the future of Go! Take the 2026 Go Developer Survey

workspace

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package workspace resolves a repository workspace and describes its index database without writing to it. The console (`seamark tui`) reads the index only through it, because the store opener migrates. The CLI commands classify the database with Probe before they open it, so both read the index meta by one rule.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotDirectory = errors.New("workspace is not a directory")

ErrNotDirectory reports a workspace path that does not name a directory. The console checks this before it enters full-screen mode.

Functions

This section is empty.

Types

type IndexProbe

type IndexProbe struct {
	State IndexState
	// Path is the database path that was probed.
	Path string
	// Schema is the stored schema version; 0 when unknown.
	Schema int
	// Supported is the schema version this binary reads.
	Supported int
	// Root is the effective repository root. It is the meta repo_root
	// when the probe reads one, else the workspace root.
	Root string
	// IndexedAt is the last index time in Unix seconds; 0 when unknown.
	IndexedAt int64
	// Err holds the probe failure for IndexUnreadable, IndexNewer and
	// IndexOlder. It is nil for the other states.
	Err error
}

IndexProbe describes the index database. Probe fills it without a write; SQLite may still create its -wal and -shm side files.

func OpenReadOnly

func OpenReadOnly(ws Workspace) (*store.Store, IndexProbe, error)

OpenReadOnly opens the index database read-only and returns a fresh probe. It fails unless the probe state is readable. The caller closes the store promptly, because a view snapshot is not a lock.

func Probe

func Probe(ws Workspace) IndexProbe

Probe classifies the index database of ws without writing to it.

type IndexState

type IndexState int

IndexState classifies the index database for display and actions.

const (
	// IndexAbsent means no database file exists.
	IndexAbsent IndexState = iota
	// IndexUnreadable means the database file exists but a read failed.
	IndexUnreadable
	// IndexNewer means a newer seamark wrote the schema.
	IndexNewer
	// IndexOlder means an older schema; `seamark index` migrates it.
	IndexOlder
	// IndexNotIndexed means the database holds decisions but no index
	// run, for example after `seamark state import`.
	IndexNotIndexed
	// IndexReady means the database is indexed and readable.
	IndexReady
)

func (IndexState) Readable

func (s IndexState) Readable() bool

Readable reports whether OpenReadOnly can open the database.

func (IndexState) String

func (s IndexState) String() string

String returns a stable lower-case name for the state.

type Workspace

type Workspace struct {
	// Root is the absolute repository root. It is the git top level
	// when git knows the directory, else the absolute directory.
	Root string
	// DBPath is the index database path. It is the --db value when set,
	// else <Root>/.seamark/index.db, the same path `seamark index` writes.
	// Resolve makes a --db value absolute; Locate keeps it as given.
	DBPath string
}

Workspace is a resolved repository root and its index database path.

func Locate

func Locate(dir, dbFlag string) (Workspace, error)

Locate derives the root and the database path without the checks of Resolve. A missing dir is no error, and a relative dbFlag stays as given. The CLI commands use it, because they report a missing workspace in their own words and print --db as the user wrote it. It returns the resolver error unchanged for the same reason.

func Resolve

func Resolve(dir, dbFlag string) (Workspace, error)

Resolve validates dir and derives the database path. It creates nothing and runs only `git rev-parse`.

Jump to

Keyboard shortcuts

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