config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultWorktreeFormat = "{repo}-{branch}"

DefaultWorktreeFormat is the default format for worktree folder names

Variables

This section is empty.

Functions

func Init

func Init(force bool) (string, error)

Init creates a default config file at ~/.config/wt/config.toml If force is true, overwrites existing file Returns the path to the created file

func ValidatePath

func ValidatePath(path, fieldName string) error

ValidatePath checks that the path is absolute or starts with ~ Returns error if path is relative (like "." or "..")

Types

type CloneConfig

type CloneConfig struct {
	Forge string      `toml:"forge"` // default forge: "github" or "gitlab"
	Org   string      `toml:"org"`   // default organization when not specified
	Rules []CloneRule `toml:"rules"` // pattern-based rules
}

CloneConfig holds clone-related configuration

func (*CloneConfig) GetForgeForRepo

func (c *CloneConfig) GetForgeForRepo(repoSpec string) string

GetForgeForRepo returns the forge name for a given repo spec (e.g., "org/repo") Matches against clone rules in order, returns default if no match

type CloneRule

type CloneRule struct {
	Pattern string `toml:"pattern"` // glob pattern like "n26/*" or "company/*"
	Forge   string `toml:"forge"`   // "github" or "gitlab"
}

CloneRule maps a pattern to a forge

type Config

type Config struct {
	WorktreeDir    string            `toml:"worktree_dir"`
	RepoDir        string            `toml:"repo_dir"` // optional: where to find repos for -r/-l
	WorktreeFormat string            `toml:"worktree_format"`
	BaseRef        string            `toml:"base_ref"`     // "local" or "remote" (default: "remote")
	DefaultSort    string            `toml:"default_sort"` // "id", "repo", "branch", "commit" (default: "id")
	Hooks          HooksConfig       `toml:"-"`            // custom parsing needed
	Clone          CloneConfig       `toml:"clone"`
	Merge          MergeConfig       `toml:"merge"`
	Hosts          map[string]string `toml:"hosts"` // domain -> forge type mapping
}

Config holds the wt configuration

func Default

func Default() Config

Default returns the default configuration

func Load

func Load() (Config, error)

Load reads config from ~/.config/wt/config.toml Returns Default() if file doesn't exist (no error) Returns error only if file exists but is invalid

func (*Config) RepoScanDir

func (c *Config) RepoScanDir() string

RepoScanDir returns the directory to scan for repositories. Returns RepoDir if set, otherwise falls back to WorktreeDir.

type Hook

type Hook struct {
	Command     string   `toml:"command"`
	Description string   `toml:"description"`
	On          []string `toml:"on"` // commands this hook runs on (empty = only via --hook)
}

Hook defines a post-create hook

type HooksConfig

type HooksConfig struct {
	Hooks map[string]Hook `toml:"-"` // parsed from [hooks.NAME] sections
}

HooksConfig holds hook-related configuration

type MergeConfig

type MergeConfig struct {
	Strategy string `toml:"strategy"` // "squash", "rebase", or "merge"
}

MergeConfig holds merge-related configuration

Jump to

Keyboard shortcuts

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