Skip to content

Commit

Permalink
fix: don't extra extend config if lefthook-local.yml is missing (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox authored Mar 13, 2023
1 parent e209c51 commit 182ae44
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions internal/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ func mergeAll(fs afero.Fs, repo *git.Repository) (*viper.Viper, error) {
return nil, err
}

if err := merge("lefthook-local", "", extends); err != nil {
if err := merge("lefthook-local", "", extends); err == nil {
if err = extend(extends, repo.RootPath); err != nil {
return nil, err
}
} else {
var notFoundErr viper.ConfigFileNotFoundError
if ok := errors.As(err, &notFoundErr); !ok {
return nil, err
}
}

if err := extend(extends, repo.RootPath); err != nil {
return nil, err
}

return extends, nil
}

Expand Down Expand Up @@ -135,6 +135,7 @@ func mergeRemote(fs afero.Fs, repo *git.Repository, v *viper.Viper) error {

// extend merges all files listed in 'extends' option into the config.
func extend(v *viper.Viper, root string) error {
log.Debugf("extends %v\n", v.GetStringSlice("extends"))
for i, path := range v.GetStringSlice("extends") {
if !filepath.IsAbs(path) {
path = filepath.Join(root, path)
Expand Down

0 comments on commit 182ae44

Please sign in to comment.