Skip to content

Add cross-platform global git hooks to strip AI-generated commit trailers#7

Merged
BenjaminMichaelis merged 3 commits into
mainfrom
copilot/add-global-git-hooks
Mar 3, 2026
Merged

Add cross-platform global git hooks to strip AI-generated commit trailers#7
BenjaminMichaelis merged 3 commits into
mainfrom
copilot/add-global-git-hooks

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

Adds global commit-msg hooks that automatically remove AI-generated trailer lines from commit messages while preserving all human Co-authored-by:, Signed-off-by:, and body content.

Hook scripts

  • git-hooks/commit-msg — bash (Linux, macOS, Windows via Git for Windows/WSL)
  • git-hooks/commit-msg.ps1 — PowerShell with an exported Remove-AITrailers function (Windows native alternative)

Strips the following patterns, case-insensitively, including indented variants (squash merges):

Trailer key Trigger
Made-with: / Generated-by: / Suggested-by: always removed
Co-authored-by: name starts with: GitHub Copilot, Claude, Amazon Q, CodeWhisperer, Gemini, ChatGPT, GPT-N, Codeium, Tabnine, Windsurf, OpenCode
Co-authored-by: email domain: @anthropic.com, @cursor.sh, @codeium.com, @cognition.ai

Trailing blank lines are collapsed when all trailers in a block are removed.

Install scripts

  • git-hooks/install.sh — sets core.hooksPath globally on Linux/macOS
  • git-hooks/install.ps1 — same for Windows; pass -UsePowerShell to install the PS1 hook + a thin bash shim instead of the bash hook

Tests & CI

  • git-hooks/tests/commit-msg.Tests.ps1 — 40 Pester 5 tests covering: all AI tools, human preservation, mixed human+AI, Signed-off-by, squash-merge indented trailers, case-insensitivity, trailing blank cleanup; bash hook tested end-to-end on non-Windows
  • .github/workflows/test-git-hooks.yml — runs on ubuntu-latest, macos-latest, windows-latest with least-privilege contents: read permissions

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.powershellgallery.com
    • Triggering command: `/usr/bin/pwsh pwsh -NoProfile -Command
      Install-Module -Name Pester -MinimumVersion 5.0 -Force -SkipPublisherCheck -Scope CurrentUser 2>&1 | Out-Null
      Import-Module Pester -MinimumVersion 5.0

$config = New-PesterConfiguration
$config.Run.Path = 'git-hooks/tests/commit-msg.Tests.ps1'
$config.Ou` (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Cross platform git hook scripts</issue_title>
<issue_description>I want a script per platform we are installing to (macos/linux, can be same script if it works) and windows (all 3 can be the same if they can) that is a global git hook that removes like "Made-with: Cursor" and similar from git commit messages or or ones from copilot with co-authors and similar. it should work with like Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> or Made-with: Cursor or Co-authored-by: GitHub Copilot <noreply@github.com> and similar (Amazon, gemini, codeium, opencode, different models, etc.)

It needs to work with various git commit patterns that we should make sure we have test coverage over (and test in github actions if we can?) to make sure that for like a basic commit message it works, when there is a real human co-author that that is preserved, that if there is a squash-merge separator and multiple AI trailers it works, etc.

We need to make sure that all human co-author and signed-off-by lines are preserved and the rest of commit message bodies remain untouched.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits March 3, 2026 20:16
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add cross platform git hook scripts for commit messages Add cross-platform global git hooks to strip AI-generated commit trailers Mar 3, 2026
@BenjaminMichaelis BenjaminMichaelis marked this pull request as ready for review March 3, 2026 20:23
@BenjaminMichaelis BenjaminMichaelis merged commit b237723 into main Mar 3, 2026
6 checks passed
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.

Cross platform git hook scripts

2 participants