Skip to content

Commit

Permalink
chore: remove any reference to viper
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Dec 3, 2024
1 parent e033f2c commit 4e854c3
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 37 deletions.
9 changes: 1 addition & 8 deletions internal/config/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 0 additions & 1 deletion internal/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ type ConfigNotFoundError struct {
message string
}

// Error returns message of viper.ConfigFileNotFoundError.
func (err ConfigNotFoundError) Error() string {
return err.message
}
Expand Down
28 changes: 0 additions & 28 deletions internal/config/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
// }

0 comments on commit 4e854c3

Please sign in to comment.