Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigDir(configPath string) string
- func Discover(startDir string) (string, error)
- func Register(root *cobra.Command)
- func RelPath(cfgPath, absPath string) (string, error)
- func ResolveRepoPath(cfgPath, repoPath string) (string, error)
- func Save(configPath string, cfg *WorkspaceConfig) error
- func SaveLocal(configPath string, ctx ContextConfig) error
- func SortedStringKeys[V any](values map[string]V) []string
- func SortedWorktreeBranchNames(branches map[string]string) []string
- func WorktreeRepoName(setName, branch string) string
- type ContextConfig
- type GroupConfig
- type RepoConfig
- type WorkspaceConfig
- type WorkspaceMeta
- type WorktreeConfig
Constants ¶
const ConfigFileName = ".gitw"
Variables ¶
var ErrNotFound = errors.New("no .gitw found in current directory or any parent")
Functions ¶
func Discover ¶
Discover searches for .gitw starting from startDir and walking up to the filesystem root. If the GIT_W_CONFIG environment variable is set, it is returned directly without any filesystem check.
func ResolveRepoPath ¶
ResolveRepoPath resolves a repo path from config against cfgPath's directory.
func Save ¶
func Save(configPath string, cfg *WorkspaceConfig) error
Save writes cfg to configPath atomically (write to .tmp, then rename). Only the workspace, repos, and groups sections are written; context lives in .gitw.local.
func SaveLocal ¶
func SaveLocal(configPath string, ctx ContextConfig) error
SaveLocal writes the context section to configPath+".local" atomically.
func SortedStringKeys ¶
SortedStringKeys returns string map keys in deterministic order.
func SortedWorktreeBranchNames ¶
SortedWorktreeBranchNames returns branch names in deterministic order. It is an alias for SortedStringKeys, kept for semantic clarity at call sites.
func WorktreeRepoName ¶
WorktreeRepoName returns the synthesized repo name for a set+branch.
Types ¶
type ContextConfig ¶
type ContextConfig struct {
Active string `toml:"active"`
}
ContextConfig holds the active context (stored in .gitw.local).
type GroupConfig ¶
type GroupConfig struct {
Repos []string `toml:"repos"`
Path string `toml:"path,omitempty"` // optional; used for auto-context detection
}
GroupConfig is a named set of repos.
type RepoConfig ¶
type RepoConfig struct {
Path string `toml:"path"`
URL string `toml:"url,omitempty"`
Flags []string `toml:"flags,omitempty"`
}
RepoConfig represents one tracked repository.
type WorkspaceConfig ¶
type WorkspaceConfig struct {
Workspace WorkspaceMeta `toml:"workspace"`
Context ContextConfig `toml:"context"` // sourced from .gitw.local
Repos map[string]RepoConfig `toml:"repos"`
Groups map[string]GroupConfig `toml:"groups"`
Worktrees map[string]WorktreeConfig `toml:"worktrees"`
}
WorkspaceConfig is the merged result of `.gitw` and `.gitw.local`. Repos and Groups maps are always non-nil after loading.
func Load ¶
func Load(configPath string) (*WorkspaceConfig, error)
Load reads configPath `.gitw` and merges `.gitw.local` if present. Returns a WorkspaceConfig with non-nil Repos and Groups maps.
func LoadCWD ¶
func LoadCWD(override string) (*WorkspaceConfig, string, error)
LoadCWD discovers and loads the workspace config, starting from the current working directory. If override is non-empty it is used as the config path directly (e.g. from the --config flag), bypassing discovery.
func LoadConfig ¶
func LoadConfig(cmd *cobra.Command) (*WorkspaceConfig, string, error)
LoadConfig reads the --config flag from the root command and loads the workspace config.
func (*WorkspaceConfig) AddRepoToGroup ¶
func (c *WorkspaceConfig) AddRepoToGroup(group, name string)
AddRepoToGroup appends name to the named group, creating the group if absent. It is idempotent: if name is already in the group, it is not added again.
func (WorkspaceConfig) AutoGitignoreEnabled ¶
func (c WorkspaceConfig) AutoGitignoreEnabled() bool
AutoGitignoreEnabled reports whether auto-gitignore is on (nil means default true).
func (*WorkspaceConfig) RemoveRepoFromManualGroups ¶
func (c *WorkspaceConfig) RemoveRepoFromManualGroups(repoName string)
RemoveRepoFromManualGroups removes repoName from every group that is not synthesized from a worktree set. Must be called before deleting the set from cfg.Worktrees so the synthesized group can still be identified.
type WorkspaceMeta ¶
type WorkspaceMeta struct {
Name string `toml:"name"`
AutoGitignore *bool `toml:"auto_gitignore"` // nil means true (default on)
}
WorkspaceMeta holds top-level workspace settings.