diff --git a/cmd/install.go b/cmd/install.go index ef2313e5..9f060744 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -36,7 +36,8 @@ var availableHooks = [...]string{ } var checkSumHook = "prepare-commit-msg" -var force bool +var force bool // ignore sync information +var aggressive bool // remove all files from .git/hooks var installCmd = &cobra.Command{ Use: "install", @@ -50,13 +51,14 @@ var appFs = afero.NewOsFs() func init() { rootCmd.PersistentFlags().BoolVarP(&force, "force", "f", false, "reinstall hooks without checking config version") + rootCmd.PersistentFlags().BoolVarP(&aggressive, "aggresive", "a", false, "remove all hooks from .git/hooks dir and install lefthook hooks") rootCmd.AddCommand(installCmd) } // InstallCmdExecutor execute basic configuration func InstallCmdExecutor(args []string, fs afero.Fs) { if yes, _ := afero.Exists(fs, getConfigYamlPath()); yes { - if !isConfigSync(fs) || force { + if !isConfigSync(fs) || force || aggressive { log.Println(au.Cyan("SYNCING"), au.Bold("lefthook.yml")) DeleteGitHooks(fs) AddGitHooks(fs) diff --git a/cmd/uninstall.go b/cmd/uninstall.go index 2b77d39f..61649fc2 100644 --- a/cmd/uninstall.go +++ b/cmd/uninstall.go @@ -60,7 +60,7 @@ func DeleteGitHooks(fs afero.Fs) { hooks, _ := afero.ReadDir(fs, hooksPath) for _, file := range hooks { hookFile := filepath.Join(hooksPath, file.Name()) - if isLefthookFile(hookFile) { + if isLefthookFile(hookFile) || aggressive { err := fs.Remove(hookFile) if err == nil { VerbosePrint(hookFile, "removed")