Documentation
¶
Overview ¶
Package config provides severity configuration loading from YAML files. It supports global, local repo, and remote config sources with defined precedence: narrower scope (more specific) overrides broader scope.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigYAML ¶
func DefaultConfigYAML() []byte
DefaultConfigYAML returns the default configuration YAML content matching the runtime default severity policy.
func GlobalPath ¶
GlobalPath returns the global config file path for the given user config directory. Returns an error if userConfigDir is empty.
func RepoNarrowPath ¶
RepoNarrowPath returns the path to .github/gh-pr-todo.yml at the root of the repository containing cwd. Returns an error if cwd is not inside a Git repository.
func RepoRootPath ¶
RepoRootPath returns the path to .gh-pr-todo.yml at the root of the repository containing cwd. Returns an error if cwd is not inside a Git repository.
func WriteDefault ¶
WriteDefault writes the default config YAML to path. If force is false, it refuses to overwrite an existing file. Parent directories are created as needed.
Types ¶
type Config ¶
type Config struct {
Severities map[string]todotype.Severity
Ignored map[string]bool
Found bool // true if at least one config file was found and parsed
}
Config holds parsed severity overrides and ignored types from configuration files.
func LoadGlobal ¶
LoadGlobal loads the user-level global config file if it exists. Returns an empty/nil-map Config if the file does not exist.
func LoadLocal ¶
LoadLocal loads config from global, repo root, and repo .github paths with whole-file replacement: each existing file replaces the entire previous config. Precedence (later wins): global < repo root .gh-pr-todo.yml < repo .github/gh-pr-todo.yml. If any repo config exists, global content does not survive. Missing files are silently ignored; parse errors are returned.
func LoadRemote ¶
func LoadRemote(fetcher RemoteConfigFetcher, repo, pr string) (Config, error)
LoadRemote loads config files from remote repository references. Precedence: PR head > PR base > default branch. Within each scope, .github/gh-pr-todo.yml replaces .gh-pr-todo.yml entirely.
type RemoteConfigFetcher ¶
type RemoteConfigFetcher interface {
// FetchRemoteConfigRefs returns the relevant refs for remote config loading.
FetchRemoteConfigRefs(repo, pr string) (RemoteConfigRefs, error)
// FetchFileAtRef fetches a file from the given repo at a specific ref.
// Returns (nil, false, nil) if the file is not found (404).
FetchFileAtRef(repo, path, ref string) ([]byte, bool, error)
}
RemoteConfigFetcher is the interface for fetching remote config files from a GitHub repository.
type RemoteConfigRefs ¶
type RemoteConfigRefs struct {
DefaultBranchRef string // e.g. "main"
DefaultRepo string // e.g. "owner/repo"
BaseBranchRef string // e.g. "main" (empty if no PR)
BaseRepo string // e.g. "owner/repo" (empty if no PR)
HeadRefOid string // e.g. "abc123def" (empty if no PR)
HeadRepo string // e.g. "forkuser/repo" (empty if no PR)
}
RemoteConfigRefs holds repository references used for remote config loading.