Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't extra extend config if lefthook-local.yml is missing #444

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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