Skip to content

Add git pre-commit hooks for code quality validation#2534

Open
dpaulson45 wants to merge 1 commit into
mainfrom
dpaul-GitHooks
Open

Add git pre-commit hooks for code quality validation#2534
dpaulson45 wants to merge 1 commit into
mainfrom
dpaul-GitHooks

Conversation

@dpaulson45
Copy link
Copy Markdown
Member

@dpaulson45 dpaulson45 commented May 2, 2026

Summary

Adds git pre-commit hooks that validate staged files before commit:

  • Test-SensitiveData.ps1 - Blocks unrecognized email domains, bare domain names, and public IPs in test data files
  • Test-HealthCheckerScenarioRunCount.ps1 - Blocks commits if test files exceed 5 SetDefaultRunOfHealthChecker pipeline runs (benchmarked optimal max)
  • Test-ScriptAnalyzer.ps1 - Blocks PSScriptAnalyzer errors and warnings on staged PowerShell files

Setup

One-time after cloning:

.github\Install-GitHooks.ps1

Uses git config core.hooksPath so hook updates sync automatically on git pull.

Files

  • .github/GitHooks/ - Hook scripts (bash wrapper + PowerShell)
  • .github/Install-GitHooks.ps1 - One-command setup
  • CONTRIBUTING.md - Added Git Hooks section

@dpaulson45 dpaulson45 requested a review from a team as a code owner May 2, 2026 17:56
Copilot AI review requested due to automatic review settings May 2, 2026 17:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .github/GitHooks/pre-commit.ps1 Outdated
Comment thread .github/GitHooks/pre-commit.ps1 Outdated
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
Comment thread .github/GitHooks/Test-SensitiveData.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
Comment thread .github/GitHooks/Test-HealthCheckerScenarioRunCount.ps1 Outdated
Comment thread .github/GitHooks/Test-HealthCheckerScenarioRunCount.ps1
@dpaulson45 dpaulson45 requested a review from Copilot May 4, 2026 17:27
@dpaulson45
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .github/GitHooks/Test-SensitiveData.ps1 Outdated
Comment thread .github/GitHooks/Test-SensitiveData.ps1 Outdated
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Comment thread .github/GitHooks/Test-SensitiveData.ps1 Outdated
Comment thread .github/GitHooks/Test-HealthCheckerScenarioRunCount.ps1 Outdated
Comment thread .github/GitHooks/Test-HealthCheckerScenarioRunCount.ps1 Outdated
Comment thread .github/Install-GitHooks.ps1
Comment thread .github/Install-GitHooks.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Comment thread .github/GitHooks/Test-HealthCheckerScenarioRunCount.ps1
Comment thread .github/GitHooks/pre-commit.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
@dpaulson45 dpaulson45 requested a review from Copilot May 6, 2026 15:04
@dpaulson45 dpaulson45 requested review from Copilot and removed request for Copilot May 7, 2026 18:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
Comment thread .github/GitHooks/Test-HealthCheckerScenarioRunCount.ps1
Comment thread CONTRIBUTING.md Outdated
Comment thread .github/Install-GitHooks.ps1 Outdated
@dpaulson45 dpaulson45 requested a review from Copilot May 7, 2026 18:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Comment thread .github/GitHooks/Test-HealthCheckerScenarioRunCount.ps1
Comment thread .github/GitHooks/Test-HealthCheckerScenarioRunCount.ps1
Comment thread .github/GitHooks/Test-HealthCheckerScenarioRunCount.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Comment thread .github/GitHooks/Test-SensitiveData.ps1 Outdated
Comment thread .github/GitHooks/pre-commit
@dpaulson45 dpaulson45 requested a review from Copilot May 7, 2026 19:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comment thread .github/Install-GitHooks.ps1 Outdated
Comment thread .github/GitHooks/pre-commit
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Comment thread .github/Install-GitHooks.ps1 Outdated
Comment thread .github/Install-GitHooks.ps1 Outdated
Comment thread .github/GitHooks/pre-commit
Comment thread .github/GitHooks/pre-commit.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
Comment thread .github/GitHooks/Test-SensitiveData.ps1 Outdated
Comment thread .github/GitHooks/Test-SensitiveData.ps1 Outdated
Comment thread CONTRIBUTING.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@dpaulson45 dpaulson45 force-pushed the dpaul-GitHooks branch 2 times, most recently from a261b11 to ca446b1 Compare May 8, 2026 15:40
@dpaulson45 dpaulson45 requested a review from Copilot May 19, 2026 17:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread .github/GitHooks/Test-HealthCheckerScenarioRunCount.ps1
Comment thread .github/Install-GitHooks.ps1 Outdated
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1 Outdated
@dpaulson45 dpaulson45 requested a review from Copilot May 19, 2026 18:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Comment thread .github/agents/pr-review-loop.agent.md Outdated
Comment thread .github/Install-GitHooks.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Comment thread .github/agents/pr-review-loop.agent.md Outdated
Comment thread .github/skills/dependency-analysis/SKILL.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Comment thread CONTRIBUTING.md Outdated
Comment thread .github/Install-GitHooks.ps1
Comment thread .github/GitHooks/pre-commit
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Comment thread .github/agents/pr-review-loop.agent.md Outdated
Comment thread .github/agents/pr-review-loop.agent.md Outdated
Comment thread .github/skills/dependency-analysis/SKILL.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Comment thread .github/GitHooks/Test-SensitiveData.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Comment thread .github/GitHooks/pre-commit.ps1
Comment thread .github/GitHooks/pre-commit
Comment thread .github/agents/pr-review-loop.agent.md Outdated
Comment thread .github/skills/dependency-analysis/SKILL.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.

Comment thread .github/skills/dependency-analysis/Get-DependencyCascade.ps1 Outdated
Comment thread .github/GitHooks/pre-commit.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Comment thread .github/GitHooks/Test-SensitiveData.ps1
Comment thread CONTRIBUTING.md
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.

Comment thread .github/GitHooks/pre-commit
Comment thread .github/skills/dependency-analysis/Get-DependencyCascade.ps1 Outdated
Comment thread .github/Install-GitHooks.ps1
Comment thread .github/Install-GitHooks.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
Comment thread .github/GitHooks/Test-ScriptAnalyzer.ps1
@dpaulson45 dpaulson45 changed the base branch from dpaul-Copilot to main May 20, 2026 14:08
dpaulson45 added a commit that referenced this pull request May 20, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants