Add cross-platform global git hooks to strip AI-generated commit trailers#7
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds global
commit-msghooks that automatically remove AI-generated trailer lines from commit messages while preserving all humanCo-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 exportedRemove-AITrailersfunction (Windows native alternative)Strips the following patterns, case-insensitively, including indented variants (squash merges):
Made-with:/Generated-by:/Suggested-by:Co-authored-by:Co-authored-by:@anthropic.com,@cursor.sh,@codeium.com,@cognition.aiTrailing blank lines are collapsed when all trailers in a block are removed.
Install scripts
git-hooks/install.sh— setscore.hooksPathglobally on Linux/macOSgit-hooks/install.ps1— same for Windows; pass-UsePowerShellto install the PS1 hook + a thin bash shim instead of the bash hookTests & 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 onubuntu-latest,macos-latest,windows-latestwith least-privilegecontents: readpermissionsWarning
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.comInstall-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)
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.