diff --git a/internal/config/hook.go b/internal/config/hook.go index 18f98046..15278f62 100644 --- a/internal/config/hook.go +++ b/internal/config/hook.go @@ -12,15 +12,8 @@ const CMD = "{cmd}" var errPipedAndParallelSet = errors.New("conflicting options 'piped' and 'parallel' are set to 'true', remove one of this option from hook group") type Hook struct { - // Should be unmarshalled with `mapstructure:"commands"` - // But replacing '{cmd}' is still an issue - // Unmarshalling it manually, so omit auto unmarshalling Commands map[string]*Command `json:"commands,omitempty" mapstructure:"-" toml:"commands,omitempty" yaml:",omitempty"` - - // Should be unmarshalled with `mapstructure:"scripts"` - // But parsing keys with dots in it is still an issue: https://github.com/spf13/viper/issues/324 - // Unmarshalling it manually, so omit auto unmarshalling - Scripts map[string]*Script `json:"scripts,omitempty" mapstructure:"-" toml:"scripts,omitempty" yaml:",omitempty"` + Scripts map[string]*Script `json:"scripts,omitempty" mapstructure:"-" toml:"scripts,omitempty" yaml:",omitempty"` Files string `json:"files,omitempty" mapstructure:"files" toml:"files,omitempty" yaml:",omitempty"` Parallel bool `json:"parallel,omitempty" mapstructure:"parallel" toml:"parallel,omitempty" yaml:",omitempty"` diff --git a/internal/config/load.go b/internal/config/load.go index 585502c9..7946f0ba 100644 --- a/internal/config/load.go +++ b/internal/config/load.go @@ -51,7 +51,6 @@ type ConfigNotFoundError struct { message string } -// Error returns message of viper.ConfigFileNotFoundError. func (err ConfigNotFoundError) Error() string { return err.message } diff --git a/internal/config/script.go b/internal/config/script.go index cf7d90ea..df3e71f0 100644 --- a/internal/config/script.go +++ b/internal/config/script.go @@ -28,31 +28,3 @@ func (s Script) DoSkip(state func() git.State) bool { func (s Script) ExecutionPriority() int { return s.Priority } - -// `scripts` are unmarshalled manually because viper -// uses "." as a key delimiter. So, this definition: -// -// ```yaml -// scripts: -// -// "example.sh": -// runner: bash -// -// ``` -// -// Unmarshals into this: -// -// ```yaml -// scripts: -// -// example: -// sh: -// runner: bash -// -// ``` -// -// This is not an expected behavior and cannot be controlled yet -// Working with GetStringMap is the only way to get the structure "as is". -// func unmarshal(input, output interface{}) error { -// return mapstructure.WeakDecode(input, &output) -// }