config

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubCommandName = "zf"
	ProgName       = "git-" + SubCommandName
)

Variables

This section is empty.

Functions

func DefaultTOML added in v0.7.0

func DefaultTOML() []byte

DefaultTOML returns the raw embedded default configuration bytes.

func HomeDir added in v0.5.0

func HomeDir() (string, error)

HomeDir returns the configuration directory path in the user home directory where live the config file.

func HomePath added in v0.5.0

func HomePath() (string, error)

HomePath returns the configuration file path in the user home directory.

func RepoDir added in v0.5.0

func RepoDir() string

RepoDir returns the repository's git directory path. For normal repos this is <worktree>/.git; for submodules and linked worktrees the real directory is resolved from the gitfile at <worktree>/.git.

func RepoPath added in v0.5.0

func RepoPath() string

RepoPath returns the configuration file path in the git repository of the project.

Types

type AppConfig

type AppConfig struct {
	ProgName      string              `json:"-" toml:"-" mapstructure:"-"`
	CommitTypes   []CommitTypeOption  `json:"commit-types"   toml:"commit-types"   mapstructure:"commit-types"`
	CommitMessage CommitMessageConfig `json:"commit-message" toml:"commit-message" mapstructure:"commit-message"`
	Branch        BranchConfig        `json:"branch"         toml:"branch"         mapstructure:"branch"`
	IssueTracker  IssueTrackerConfig  `json:"issue-tracker"  toml:"issue-tracker"  mapstructure:"issue-tracker"`
}

AppConfig is the top-level configuration for the application.

func Load

func Load() (*AppConfig, error)

Load parses the embedded default.toml then overlays any values present in the global viper instance. Each config section is handled individually so that a partial override (e.g. only commit-message.items) preserves unset defaults. viper.Sub is avoided because it silently returns nil for array-typed keys.

type BranchConfig

type BranchConfig struct {
	Base        string `json:"base"          toml:"base"          mapstructure:"base"`
	Remote      string `json:"remote"        toml:"remote"        mapstructure:"remote"`
	UseWorktree *bool  `json:"use-worktree"  toml:"use-worktree"  mapstructure:"use-worktree"`
	WorktreeDir string `json:"worktree-dir"  toml:"worktree-dir"  mapstructure:"worktree-dir"`
}

BranchConfig holds branch-related settings. Base is the branch new branches are cut from; empty means auto-detect. Remote is the git remote name to use; empty means auto-detect.

type CommitItem

type CommitItem struct {
	Name     string             `json:"name"     toml:"name"     mapstructure:"name"`
	Desc     string             `json:"desc"     toml:"desc"     mapstructure:"desc"`
	Form     string             `json:"form"     toml:"form"     mapstructure:"form"`
	Required bool               `json:"required" toml:"required" mapstructure:"required"`
	Options  []CommitItemOption `json:"options"  toml:"options"  mapstructure:"options"`
	Value    string             `json:"-"        toml:"-"        mapstructure:"-"`
}

CommitItem describes one field in the commit message form. Value is written by the form after the user submits.

type CommitItemOption

type CommitItemOption struct {
	Name string `json:"name" toml:"name" mapstructure:"name"`
	Desc string `json:"desc" toml:"desc" mapstructure:"desc"`
}

CommitItemOption is a selectable option within a CommitItem select field.

type CommitMessageConfig

type CommitMessageConfig struct {
	Items    []CommitItem `json:"items"    toml:"items"    mapstructure:"items"`
	Template string       `json:"template" toml:"template" mapstructure:"template"`
}

CommitMessageConfig holds the ordered list of form fields and the Go template used to assemble the commit message.

type CommitTypeOption

type CommitTypeOption struct {
	Name string `json:"name" toml:"name" mapstructure:"name"`
	Desc string `json:"desc" toml:"desc" mapstructure:"desc"`
}

CommitTypeOption is a single commit type entry (e.g. "feat", "fix").

type IssueTrackerConfig

type IssueTrackerConfig struct {
	Type     string   `json:"type"     toml:"type"     mapstructure:"type"`
	URL      string   `json:"url"      toml:"url"      mapstructure:"url"`
	Token    string   `json:"token"    toml:"token"    mapstructure:"token"`
	Projects []string `json:"projects" toml:"projects" mapstructure:"projects"`
}

IssueTrackerConfig holds connection parameters for one tracker instance. Never log values of this type — Token is a secret.

Jump to

Keyboard shortcuts

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