gitRemoveHook removes commitlint from git config by unsetting core.hooksPath. It prompts for confirmation before making any changes. Hook files are left intact - the user can remove them manually if needed.
(isGlobal bool)
| 16 | // It prompts for confirmation before making any changes. |
| 17 | // Hook files are left intact - the user can remove them manually if needed. |
| 18 | func gitRemoveHook(isGlobal bool) error { |
| 19 | scope := "local" |
| 20 | if isGlobal { |
| 21 | scope = "global" |
| 22 | } |
| 23 | confirmed, err := promptConfirm(fmt.Sprintf("Unset core.hooksPath from %s git config?", scope)) |
| 24 | if err != nil { |
| 25 | return err |
| 26 | } |
| 27 | if !confirmed { |
| 28 | fmt.Println("aborted") |
| 29 | return nil |
| 30 | } |
| 31 | |
| 32 | if err := unsetGitConf(isGlobal); err != nil { |
| 33 | return fmt.Errorf("could not unset git core.hooksPath: %w", err) |
| 34 | } |
| 35 | |
| 36 | fmt.Println("commitlint hook removed successfully") |
| 37 | fmt.Println("note: hook files were not removed - delete them manually if no longer needed") |
| 38 | return nil |
| 39 | } |
| 40 | |
| 41 | // unsetGitConf removes the core.hooksPath entry from git config (local or global). |
| 42 | func unsetGitConf(isGlobal bool) error { |
no test coverage detected