Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrStaleGlobalConfig = errors.New("stale global config entry")
ErrStaleGlobalConfig indicates the global config references a project path but the kan data directory doesn't exist. This can happen if the user manually deletes the .kan/ directory.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
ProjectRoot string // Absolute path to project root
DataLocation string // Relative path for kan data (empty = default .kan/)
WasRegistered bool // Whether this project was found in global config
ResolvedFromWorktree bool // True if redirected from a worktree to main
OriginalWorktreeRoot string // The worktree path we redirected from (empty if not redirected)
}
Result contains the discovered project root and data location.
func DiscoverProject ¶
func DiscoverProject(globalCfg *model.GlobalConfig) (*Result, error)
DiscoverProject finds the project root by walking up from cwd. Priority: 1. Directory that's a key in global config -> use configured DataLocation 2. Directory containing .kan/ -> use as self-discoverable default
Returns nil if no project found (not initialized). Returns error if global config references a path but data is missing.
func DiscoverProjectFrom ¶
func DiscoverProjectFrom(startDir string, globalCfg *model.GlobalConfig) (*Result, error)
DiscoverProjectFrom finds the project root starting from a given directory.
func ResolveWorktree ¶ added in v0.20.0
func ResolveWorktree( result *Result, resolver WorktreeResolver, globalCfg *model.GlobalConfig, isIndependent func(projectRoot, dataLocation string) bool, ) (*Result, error)
ResolveWorktree checks if the discovered project is in a git worktree and redirects to the main worktree's project if so. This makes all worktrees share the main worktree's board by default.
The isIndependent callback checks whether the discovered project has opted out of worktree sharing (via worktree_independent in project config). Pass nil to skip the independence check.
Falls back to the original result if: not in a worktree, the project opted out, the main worktree has no project, or any error occurs.
type WorktreeResolver ¶ added in v0.20.0
WorktreeResolver detects git worktrees and resolves the main worktree root.