-
Notifications
You must be signed in to change notification settings - Fork 177
feat(install): allow to install hook locally with husky #1150
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ### Fixed | ||
|
|
||
| - Install `ggshield` hooks inside `.husky/` when the repository uses Husky-managed hooks so local installs work out of the box. (#1143) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| from pathlib import Path | ||
|
|
||
| from tests.functional.utils import run_ggshield | ||
| from tests.repository import Repository | ||
|
|
||
|
|
||
| def test_install_local_detects_husky(tmp_path: Path) -> None: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect a functional test to use Husky for real. Is it doable? I think if you replace the use of
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A functional test with husky feels a bit heavy as it would introduce the need for npm and husky. As you suggested, I moved to a unit test |
||
| repo = Repository.create(tmp_path) | ||
|
|
||
| husky_dir = repo.path / ".husky" | ||
| (husky_dir / "_").mkdir(parents=True) | ||
| repo.git("config", "core.hooksPath", ".husky/_") | ||
|
|
||
| run_ggshield("install", "-m", "local", "-t", "pre-commit", cwd=repo.path) | ||
|
|
||
| husky_hook = husky_dir / "pre-commit" | ||
| assert husky_hook.is_file() | ||
| assert 'ggshield secret scan pre-commit "$@"' in husky_hook.read_text() | ||
|
|
||
| default_hook = repo.path / ".git/hooks/pre-commit" | ||
| assert not default_hook.exists() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having both
get_local_hook_dir_path()andget_local_hooks_path()is confusing. Maybe name this oneget_hooks_path_from_local_git_config()(a bit long, but unambiguous)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed to
get_git_local_hooks_path, wdyt ?