config

package
v2.10.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package config defines the configuration schema and helpers for wtp.

Index

Constants

View Source
const (
	// ConfigFileName is the default filename for the wtp configuration.
	ConfigFileName = ".wtp.yml"
	// CurrentVersion represents the current configuration version written to disk.
	CurrentVersion = "1.0"
	// DefaultBaseDir is the default directory for new worktrees relative to a repository.
	DefaultBaseDir = "../worktrees"
	// HookTypeCopy identifies a hook that copies files.
	HookTypeCopy = "copy"
	// HookTypeCommand identifies a hook that executes a command.
	HookTypeCommand = "command"
	// HookTypeSymlink identifies a hook that creates symlinks.
	HookTypeSymlink = "symlink"
)

Variables

This section is empty.

Functions

func SaveConfig

func SaveConfig(repoRoot string, config *Config) error

SaveConfig saves configuration to .git-worktree-plus.yml in the repository root

Types

type Config

type Config struct {
	Version  string   `yaml:"version"`
	Defaults Defaults `yaml:"defaults,omitempty"`
	Hooks    Hooks    `yaml:"hooks,omitempty"`
}

Config represents the wtp configuration

func LoadConfig

func LoadConfig(repoRoot string) (*Config, error)

LoadConfig loads configuration from .wtp.yml in the repository root

func (*Config) ApplyDefaults added in v2.7.0

func (c *Config) ApplyDefaults()

ApplyDefaults applies default values to the configuration in-place.

func (*Config) HasHooks

func (c *Config) HasHooks() bool

HasHooks returns true if the configuration has any post-create hooks

func (*Config) ResolveWorktreePath

func (c *Config) ResolveWorktreePath(repoRoot, worktreeName string) string

ResolveWorktreePath resolves the full path for a worktree given a name

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration without mutating it.

type Defaults

type Defaults struct {
	BaseDir string `yaml:"base_dir,omitempty"`
}

Defaults represents default configuration values

type Hook

type Hook struct {
	Type    string            `yaml:"type"` // "copy", "command", or "symlink"
	From    string            `yaml:"from,omitempty"`
	To      string            `yaml:"to,omitempty"`
	Command string            `yaml:"command,omitempty"`
	Env     map[string]string `yaml:"env,omitempty"`
	WorkDir string            `yaml:"work_dir,omitempty"`
}

Hook represents a single hook configuration

func (*Hook) ApplyDefaults added in v2.7.0

func (h *Hook) ApplyDefaults()

ApplyDefaults applies default values to a single hook in-place.

func (*Hook) Validate

func (h *Hook) Validate() error

Validate validates a single hook configuration without mutating it.

type Hooks

type Hooks struct {
	PostCreate []Hook `yaml:"post_create,omitempty"`
}

Hooks represents the post-create hooks configuration

Jump to

Keyboard shortcuts

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