Skip to content

Commit 77ae8a7

Browse files
committed
fix(hooks): limit pre-push AI attribution check to commits since latest release
Only check commits after the latest published release tag instead of scanning entire history. This prevents false positives from old commits with AI attribution that are already on origin/main from merged PRs. Changes: - Find latest v* tag merged into branch being pushed - Only scan commits after that tag - Fall back to full history if no release tags exist - Applies to both new branches and existing branches Benefits: - No false positives from historical commits - Faster push validation - Still blocks new AI attribution in unpublished code
1 parent 851299c commit 77ae8a7

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

.git-hooks/pre-push

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,26 @@ TOTAL_ERRORS=0
2626
while read local_ref local_sha remote_ref remote_sha; do
2727
# Get the range of commits being pushed.
2828
if [ "$remote_sha" = "0000000000000000000000000000000000000000" ]; then
29-
# New branch - check all commits.
30-
range="$local_sha"
29+
# New branch - find the latest published release tag to limit scope.
30+
latest_release=$(git tag --list 'v*' --sort=-version:refname --merged "$local_sha" | head -1)
31+
if [ -n "$latest_release" ]; then
32+
# Check commits since the latest published release.
33+
range="$latest_release..$local_sha"
34+
else
35+
# No release tags found - check all commits.
36+
range="$local_sha"
37+
fi
3138
else
32-
# Existing branch - check new commits.
33-
range="$remote_sha..$local_sha"
39+
# Existing branch - check new commits since remote.
40+
# Limit scope to commits after the latest published release on this branch.
41+
latest_release=$(git tag --list 'v*' --sort=-version:refname --merged "$remote_sha" | head -1)
42+
if [ -n "$latest_release" ]; then
43+
# Only check commits after the latest release that are being pushed.
44+
range="$latest_release..$local_sha"
45+
else
46+
# No release tags found - check new commits only.
47+
range="$remote_sha..$local_sha"
48+
fi
3449
fi
3550

3651
ERRORS=0

0 commit comments

Comments
 (0)