Documentation
¶
Index ¶
- Constants
- func Exists(dir string) bool
- func MergeDefaultLabels(cfg *Config) bool
- func MergeDefaultRepoSettings(cfg *Config) bool
- func MergeRepoSettings(cfg *Config, live *model.RepositorySettings, description string)
- func ValidateDuplicatePaths(cfg *Config) error
- func ValidateLabels(cfg *Config) error
- func ValidatePaths(cfg *Config) error
- func ValidateRepoSettings(cfg *Config) error
- func ValidateTopics(cfg *Config) error
- func ValidateWorkflowPermissions(cfg *Config) error
- func Write(dir string, cfg *Config, date string, verb string) error
- type Config
- type SwatchEntry
Constants ¶
const ConfigSwatchPath = ".tailor.yml"
ConfigSwatchPath is the path of the config swatch entry, which is excluded from merge because it describes the config file itself.
Variables ¶
This section is empty.
Functions ¶
func MergeDefaultLabels ¶
MergeDefaultLabels populates cfg.Labels from the embedded default configuration when the slice is empty. Both present-but-empty (labels: []) and absent (no labels key) result in len==0 after YAML unmarshalling, so both cases receive the default labels. If cfg.Labels already contains entries, the function leaves them unchanged and returns false.
func MergeDefaultRepoSettings ¶
MergeDefaultRepoSettings fills nil pointer fields in cfg.Repository from the embedded default configuration. It skips Description, Homepage, and Topics. If cfg.Repository is nil, it allocates a new RepositorySettings. Returns true when at least one field was added.
func MergeRepoSettings ¶
func MergeRepoSettings(cfg *Config, live *model.RepositorySettings, description string)
MergeRepoSettings replaces cfg.Repository with the live settings retrieved from the GitHub API. The description flag, when non-empty, overrides whatever the live settings carried. Empty string pointer fields for Description and Homepage are normalised to nil so they are omitted from YAML.
func ValidateDuplicatePaths ¶
ValidateDuplicatePaths checks that no two swatches share a path. Returns an error identifying the duplicate.
func ValidateLabels ¶
ValidateLabels checks that every label entry has valid name, color, and description fields. Rejects duplicate names (case-insensitive).
func ValidatePaths ¶
ValidatePaths checks that every swatch path in cfg matches a known embedded swatch. Returns an error listing the unrecognised path and all valid paths.
func ValidateRepoSettings ¶
ValidateRepoSettings checks that every field name in cfg.Repository matches the supported settings list. Returns an error identifying the unrecognised field and listing all valid field names.
func ValidateTopics ¶
ValidateTopics checks that every topic, if set, starts with a lowercase letter or number, contains only lowercase alphanumerics and hyphens, and does not exceed 50 characters.
func ValidateWorkflowPermissions ¶
ValidateWorkflowPermissions checks that default_workflow_permissions, if set, is either "read" or "write".
Types ¶
type Config ¶
type Config struct {
License string `yaml:"license"`
Repository *model.RepositorySettings `yaml:"repository,omitempty"`
Labels []model.LabelEntry `yaml:"labels,omitempty"`
Swatches []SwatchEntry `yaml:"swatches"`
}
Config represents the contents of .tailor.yml.
func DefaultConfig ¶
DefaultConfig returns the embedded default configuration with the given license. It parses swatches/.tailor.yml from the embedded filesystem, validates its contents, and overrides the license field.
type SwatchEntry ¶
type SwatchEntry struct {
Path string `yaml:"path"`
Alteration swatch.AlterationMode `yaml:"alteration"`
}
SwatchEntry describes a single swatch entry in the config file.
func MergeDefaultSwatches ¶
func MergeDefaultSwatches(cfg *Config) []SwatchEntry
MergeDefaultSwatches appends missing default swatch entries to cfg.Swatches. It skips the config swatch itself. Existing entries are matched by path, so an altered mode does not cause duplication. It returns the slice of newly added entries.
func MergeDefaults ¶
func MergeDefaults(cfg *Config) (swatchesAdded []SwatchEntry, repoMerged bool, labelsMerged bool)
MergeDefaults calls DefaultConfig once and delegates to the three merge functions, avoiding redundant YAML parses. Returns the newly added swatch entries and whether repo settings or labels were merged.