Skip to content

Commit

Permalink
[skip travis] add aggresive flag for install cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
A.A.Abroskin committed Jul 15, 2019
1 parent 47d1803 commit 0426936
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 0426936

Please sign in to comment.