CLI-173 E2E test for pre-commit & pre-push hooks#119
CLI-173 E2E test for pre-commit & pre-push hooks#119sophio-japharidze-sonarsource wants to merge 11 commits intomasterfrom
Conversation
SummaryAdds comprehensive E2E tests for git hook integration (pre-commit and pre-push) supporting native hooks, Husky, and pre-commit framework. Tests verify hook installation, secret detection blocking, and error handling. Also includes guidance in CLI output on how to skip hooks using the --no-verify flag. Includes extensive supporting infrastructure: test harness, unit tests, GitHub workflows, and build scripts. What reviewers should knowStart with
|
48d5d7c to
69c3626
Compare
d44fbcc to
bf737d0
Compare
69c3626 to
5b8cef0
Compare
| import { BINARY_PATH } from '../../harness/cli-runner.js'; | ||
|
|
||
| const PATH_DELIM = process.platform === 'win32' ? ';' : ':'; | ||
| function pathWithoutNodeModules(envPath: string | undefined): string { |
There was a problem hiding this comment.
This is again needed to avoid calling sonar-scanner JS dependency
5b8cef0 to
bd9b999
Compare
bd9b999 to
b36b9f2
Compare
1281605 to
eac5d17
Compare
b36b9f2 to
e0c87c5
Compare
e0c87c5 to
1bfcd37
Compare
There was a problem hiding this comment.
Conclusion: The refactoring of git-shell-fragments.ts is solid — extracting preCommitBody/prePushBody removes real duplication between the native and Husky variants, and replacing the hardcoded empty-tree SHA with $(printf '' | git mktree) correctly handles SHA-256 repos. The new E2E tests are well-structured: they exercise the full hook lifecycle including actual git commit/git push invocations against a bare remote. The one issue worth fixing before merge is a corrupted lock file entry.
8675e5d to
0aa4b9c
Compare
SonarQube reviewer guide
|
| @@ -520,14 +533,36 @@ describe('integrateGit', () => { | |||
| performSecretInstallSpy.mockRestore(); | |||
There was a problem hiding this comment.
These two tests use try/catch without expect.assertions(n). If integrateGit ever stops throwing (e.g. after a refactor), the catch block is skipped and the tests pass with zero assertions — giving false confidence.
Fix with Bun's expect DSL:
await expect(
integrateGit({ nonInteractive: true, hook: 'typo' } as unknown as IntegrateGitOptions)
).rejects.toBeInstanceOf(InvalidOptionError);or add expect.assertions(2) at the top of each test body. Same pattern applies to the 'global install' variant at line 541.
- Mark as noise




No description provided.