Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: uninstall all possible formats #523

Merged
merged 2 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading