project

package
v7.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CentralProjectDir

func CentralProjectDir(projectName string) (string, error)

CentralProjectDir returns <centralRoot>/tickets/<projectName>.

func CentralStoreRoot

func CentralStoreRoot() (string, error)

CentralStoreRoot returns the central ticket store root directory. Returns an error if central_root is not configured — run `tk init` first.

func ConfigPath

func ConfigPath() (string, error)

ConfigPath returns ~/.ticket/config.yaml.

func DetectProjectPath

func DetectProjectPath(cwd string) string

DetectProjectPath returns git top-level directory if available; otherwise cwd.

func IsConfigured

func IsConfigured() bool

IsConfigured returns true if ~/.ticket/config.yaml exists and has central_root set.

func ResolveName

func ResolveName(cfg Config, cwd string, explicit string) (name string, source string)

ResolveName resolves project name with precedence: 1) explicit override 2) config path mapping 3) git remote name 4) directory name

Names are sanitized to prevent path traversal (no ".." or path separators).

func ResolveWorkDir

func ResolveWorkDir(ticketsDir string, cfg Config) string

ResolveWorkDir returns the project's real repo working directory for a tickets directory. With the central store, ticketsDir is <centralRoot>/tickets/<project> and its parent is the central tickets dir, NOT the repo — so the project's recorded `path` from config is used when available. Falls back to the parent of ticketsDir (correct for a local .tickets/ at the repo root) when the project has no configured path.

func Save

func Save(cfg Config) error

Save writes the config to both local and shared files, splitting fields appropriately. Local gets top-level fields + per-project path. Shared gets per-project store, auto_link, auto_close, registered_at.

func SharedConfigPath

func SharedConfigPath() (string, error)

SharedConfigPath returns <central_root>/config.yaml.

Types

type Config

type Config struct {
	CentralRoot  string                   `yaml:"central_root,omitempty" json:"central_root,omitempty"`
	GitEmail     string                   `yaml:"git_email,omitempty" json:"git_email,omitempty"`
	GitName      string                   `yaml:"git_name,omitempty" json:"git_name,omitempty"`
	DefaultStore string                   `yaml:"default_store,omitempty" json:"default_store,omitempty"`
	SyncInterval string                   `yaml:"sync_interval,omitempty" json:"sync_interval,omitempty"`
	SpawnCommand string                   `yaml:"spawn_command,omitempty" json:"spawn_command,omitempty"`
	Projects     map[string]ProjectConfig `yaml:"projects"`
}

Config stores tk project configuration (merged view of local + shared).

func Load

func Load() (Config, error)

Load reads both local (~/.ticket/config.yaml) and shared (<central_root>/config.yaml) configs, merging them into a single Config. Local fields (central_root, git_email, git_name, default_store, sync_interval, spawn_command, per-project path) come from local config. Shared fields (per-project store, auto_link, auto_close, registered_at) come from shared config. Missing files are not errors — returns what's available.

func (*Config) UpsertProject

func (cfg *Config) UpsertProject(name string, project ProjectConfig)

UpsertProject inserts or updates a project entry.

type ProjectConfig

type ProjectConfig struct {
	Path         string `yaml:"path,omitempty" json:"path,omitempty"`
	Store        string `yaml:"store,omitempty" json:"store,omitempty"`
	AutoLink     bool   `yaml:"auto_link" json:"auto_link"`
	AutoClose    bool   `yaml:"auto_close" json:"auto_close"`
	RegisteredAt string `yaml:"registered_at,omitempty" json:"registered_at,omitempty"`
}

ProjectConfig stores per-project settings.

Jump to

Keyboard shortcuts

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