diff --git a/githooks/cmd/installer/installer.go b/githooks/cmd/installer/installer.go index 5379f857..9400eecd 100644 --- a/githooks/cmd/installer/installer.go +++ b/githooks/cmd/installer/installer.go @@ -848,14 +848,20 @@ func setupHookTemplates( if len(maintainedHooks) == 0 { maintainedHooks, err = hooks.GetMaintainedHooks(gitx, git.GlobalScope) log.AssertNoError(err, "Could not get config.") + } else { + // Set maintained hooks in global settings, such that + // local repository Githooks installs are in alignment + // to the setup template directory. + err = hooks.SetMaintainedHooks(gitx, maintainedHooks, git.GlobalScope) + log.AssertNoError(err, "Could not set git config.") + + maintainedHooks, err = hooks.UnwrapHookNames(maintainedHooks) + log.AssertNoErrorPanic(err, "Could not build maintained hook list.") } - allHooks, err := hooks.UnwrapHookNames(maintainedHooks) - log.AssertNoErrorPanic(err, "Could not build maintained hook list.") - nLFSHooks, err := hooks.InstallRunWrappers( hookTemplateDir, - allHooks, + maintainedHooks, func(dest string) { log.InfoF(" %s '%s'", cm.ListItemLiteral, path.Base(dest)) }, @@ -866,17 +872,12 @@ func setupHookTemplates( if nLFSHooks != 0 { log.InfoF("Installed '%v' Githooks run-wrappers and '%v' missing LFS hooks into '%s'.", - len(allHooks), nLFSHooks, hookTemplateDir) + len(maintainedHooks), nLFSHooks, hookTemplateDir) } else { log.InfoF("Installed '%v' Githooks run-wrappers into '%s'.", - len(allHooks), hookTemplateDir) + len(maintainedHooks), hookTemplateDir) } - // Set maintained hooks in global settings, such that - // local repository Githooks installs are in alignment - // to the setup template directory. - err = hooks.SetMaintainedHooks(gitx, maintainedHooks, git.GlobalScope) - log.AssertNoError(err, "Could not set git config.") } func installBinaries(