Add git pre-commit hooks for code quality validation#2534
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an optional repository-managed Git pre-commit hook setup so contributors can run a few local quality checks before committing. It fits into the repo’s existing PowerShell-centric contribution workflow by trying to catch analyzer issues, risky test data, and oversized HealthChecker scenario test files earlier.
Changes:
- Adds a hook installer plus Git hook entrypoints under
.github/GitHooks/. - Introduces three pre-commit validations: sensitive test-data scanning, HealthChecker run-count checking, and ScriptAnalyzer checks.
- Documents the optional hook setup in
CONTRIBUTING.md.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
CONTRIBUTING.md |
Documents optional pre-commit hook setup and what checks it runs. |
.github/Install-GitHooks.ps1 |
Configures core.hooksPath to use the repo-managed hooks directory. |
.github/GitHooks/pre-commit.ps1 |
Main PowerShell pre-commit orchestrator that discovers staged files and runs validators. |
.github/GitHooks/pre-commit |
Bash wrapper that launches the PowerShell pre-commit hook. |
.github/GitHooks/Test-SensitiveData.ps1 |
Scans staged test data files for suspicious email, IP, and credential patterns. |
.github/GitHooks/Test-ScriptAnalyzer.ps1 |
Runs PSScriptAnalyzer against staged PowerShell files during commit. |
.github/GitHooks/Test-HealthCheckerScenarioRunCount.ps1 |
Checks HealthChecker test files for excessive SetDefaultRunOfHealthChecker usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 14 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a261b11 to
ca446b1
Compare
68bd41e to
c060f3d
Compare
ba6a224 to
0580ce6
Compare
0580ce6 to
63f49c4
Compare
…nd 100 PR #2534 had 101 threads; thread #101 (PRRT_kwDOEQZYys6Df4HM) was missed because reviewThreads(first: 50/100) does not return threads beyond the page limit. The agent reported all threads handled while one had no reply. code-review.agent.md: - Step 3: Add pagination warning with PR #2534 as documented example - Step 6: Replace single-page query with paginated version using hasNextPage/endCursor, instructions to combine all pages pr-review-loop.agent.md: - Step 1.3: Add pagination requirement for GraphQL thread queries Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add optional pre-commit hooks that validate staged files before commit: - Sensitive data scanning on test data files (blocks unrecognized email domains, public IPs, credential-like values) - Pester test file pipeline run count checking (blocks if a test file exceeds 5 SetDefaultRunOfHealthChecker runs) - PSScriptAnalyzer validation with all CodeFormatterChecks to match CI Install via: .github/Install-GitHooks.ps1 Sets core.hooksPath to .github/GitHooks/ so hook updates are automatic. CONTRIBUTING.md updated with setup instructions and prerequisites. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
63f49c4 to
d78e0da
Compare
Summary
Adds git pre-commit hooks that validate staged files before commit:
Setup
One-time after cloning:
.github\Install-GitHooks.ps1Uses
git config core.hooksPathso hook updates sync automatically ongit pull.Files
.github/GitHooks/- Hook scripts (bash wrapper + PowerShell).github/Install-GitHooks.ps1- One-command setupCONTRIBUTING.md- Added Git Hooks section