Skip to content

Commit 0426936

Browse files
author
A.A.Abroskin
committed
[skip travis] add aggresive flag for install cmd
1 parent 47d1803 commit 0426936

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

cmd/install.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ var availableHooks = [...]string{
3636
}
3737

3838
var checkSumHook = "prepare-commit-msg"
39-
var force bool
39+
var force bool // ignore sync information
40+
var aggressive bool // remove all files from .git/hooks
4041

4142
var installCmd = &cobra.Command{
4243
Use: "install",
@@ -50,13 +51,14 @@ var appFs = afero.NewOsFs()
5051

5152
func init() {
5253
rootCmd.PersistentFlags().BoolVarP(&force, "force", "f", false, "reinstall hooks without checking config version")
54+
rootCmd.PersistentFlags().BoolVarP(&aggressive, "aggresive", "a", false, "remove all hooks from .git/hooks dir and install lefthook hooks")
5355
rootCmd.AddCommand(installCmd)
5456
}
5557

5658
// InstallCmdExecutor execute basic configuration
5759
func InstallCmdExecutor(args []string, fs afero.Fs) {
5860
if yes, _ := afero.Exists(fs, getConfigYamlPath()); yes {
59-
if !isConfigSync(fs) || force {
61+
if !isConfigSync(fs) || force || aggressive {
6062
log.Println(au.Cyan("SYNCING"), au.Bold("lefthook.yml"))
6163
DeleteGitHooks(fs)
6264
AddGitHooks(fs)

cmd/uninstall.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func DeleteGitHooks(fs afero.Fs) {
6060
hooks, _ := afero.ReadDir(fs, hooksPath)
6161
for _, file := range hooks {
6262
hookFile := filepath.Join(hooksPath, file.Name())
63-
if isLefthookFile(hookFile) {
63+
if isLefthookFile(hookFile) || aggressive {
6464
err := fs.Remove(hookFile)
6565
if err == nil {
6666
VerbosePrint(hookFile, "removed")

0 commit comments

Comments
 (0)