From 18f9f148b007f1d3d2e37da4bdb079b900bf9df9 Mon Sep 17 00:00:00 2001 From: Valentin Kiselev Date: Mon, 13 Mar 2023 17:39:25 +0300 Subject: [PATCH] fix: don't extra extend config if lefthook-local.yml is missing --- internal/config/load.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/config/load.go b/internal/config/load.go index d09fc77b..3709f7bc 100644 --- a/internal/config/load.go +++ b/internal/config/load.go @@ -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, ¬FoundErr); !ok { return nil, err } } - if err := extend(extends, repo.RootPath); err != nil { - return nil, err - } - return extends, nil } @@ -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)