Documentation
¶
Overview ¶
Package projectdir resolves project-specific state directories under $XDG_STATE_HOME/sidecar/projects/<slug>/ (defaults to ~/.local/state/sidecar/projects/<slug>/). Each project root gets a unique slug-named directory containing a meta.json that maps back to the original project path.
Index ¶
- func Lookup(projectRoot string) (string, bool)
- func LookupAll(projectRoots []string) map[string]string
- func LookupAllWithBase(base string, projectRoots []string) map[string]string
- func LookupWorktree(projectRoot, worktreePath string) (string, bool)
- func LookupWorktreeWithBase(base, projectRoot, worktreePath string) (string, bool)
- func Resolve(projectRoot string) (string, error)
- func ResolveWithBase(base, projectRoot string) (string, error)
- func WorktreeDir(projectRoot, worktreePath string) (string, error)
- func WorktreeDirContext(ctx context.Context, projectRoot, worktreePath string) (string, error)
- func WorktreeDirWithBase(base, projectRoot, worktreePath string) (string, error)
- func WorktreeKey(worktreePath string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Lookup ¶ added in v0.93.0
Lookup returns the already-registered data directory for a project root without creating anything. Diagnostics use it: a function whose job is to report what this process will write to must not itself write.
func LookupAll ¶ added in v1.0.3
LookupAll resolves many project roots in one pass over projects/.
Lookup rescans and re-reads every registered project's meta.json on each call, so resolving N roots with it costs N full scans — and a long-lived install accumulates hundreds of registered projects. Callers that need the whole configured set at once use this instead: one ReadDir, one meta.json read per candidate, regardless of how many roots are asked for.
Roots with no registered directory are absent from the result rather than mapped to an empty string, so a caller can tell "never registered" from "registered at the empty path".
func LookupAllWithBase ¶ added in v1.0.3
LookupAllWithBase is the testable form of LookupAll. base is the Sidecar state directory containing projects/.
func LookupWorktree ¶ added in v0.94.0
LookupWorktree returns the already-registered data directory for worktreePath without creating or migrating state. It is intended for read-only inventory consumers such as diagnostics and the cross-project overview.
func LookupWorktreeWithBase ¶ added in v1.0.0
LookupWorktreeWithBase is the read-only, testable form of LookupWorktree. base is the Sidecar state directory containing projects/.
func Resolve ¶
Resolve returns the data directory for the given project root path. It creates the directory (with meta.json) if it does not already exist. On subsequent calls with the same projectRoot, the existing directory is returned.
func ResolveWithBase ¶
ResolveWithBase is the exported, testable form of Resolve. base overrides the state directory (e.g. a temp dir in tests).
func WorktreeDir ¶
WorktreeDir returns the worktree-specific data directory for a project. The directory is created if it does not exist.
func WorktreeDirContext ¶ added in v0.94.0
WorktreeDirContext resolves worktree state while allowing legacy Git inventory to be cancelled with its owning lifecycle operation.
func WorktreeDirWithBase ¶
WorktreeDirWithBase is the exported, testable form of WorktreeDir. base overrides the state directory (e.g. a temp dir in tests).
func WorktreeKey ¶ added in v0.94.0
WorktreeKey is stable across restarts and independent of presentation names.
Types ¶
This section is empty.