Skip to content

Commit

Permalink
fix: uninstall all possible formats (#523)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox authored Jul 17, 2023
1 parent 193190b commit 9f47c64
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 10 additions & 6 deletions internal/lefthook/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ func (l *Lefthook) Uninstall(args *UninstallArgs) error {
}

if args.RemoveConfig {
for _, glob := range []string{
".lefthook.y*ml",
"lefthook.y*ml",
".lefthook-local.y*ml",
"lefthook-local.y*ml",
for _, name := range []string{
".lefthook",
"lefthook",
".lefthook-local",
"lefthook-local",
} {
l.removeFile(filepath.Join(l.repo.RootPath, glob))
for _, extension := range []string{
".yml", ".yaml", ".toml", ".json",
} {
l.removeFile(filepath.Join(l.repo.RootPath, name+extension))
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions testdata/uninstall.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ exists .git/hooks/pre-push
exec lefthook uninstall
! exists .git/hooks-pre-push
exists lefthook.yml
exists .lefthook-local.toml

exec lefthook install
exists .git/hooks/pre-push
exec lefthook uninstall -c
! exists .git/hooks-pre-push
! exists lefthook.yml
! exists .lefthook-local.toml

-- lefthook.yml --
pre-push:
commands:
echo:
run: echo pre-push


-- .lefthook-local.toml --
[pre-commit.commands.echo]
run = "echo pre-commit"

0 comments on commit 9f47c64

Please sign in to comment.