Skip to content

fix(hooks): gate --allow-unknown-hook-name on git 2.54+#728

Merged
aviator-app[bot] merged 1 commit intomasterfrom
fix-hooks-threshold-2.54
Apr 22, 2026
Merged

fix(hooks): gate --allow-unknown-hook-name on git 2.54+#728
aviator-app[bot] merged 1 commit intomasterfrom
fix-hooks-threshold-2.54

Conversation

@jainankit
Copy link
Copy Markdown
Contributor

Summary

Follow-up to #727. That PR gated --allow-unknown-hook-name at git 2.44 based on incorrect version information. The flag was actually introduced in git 2.54 alongside the stricter hook-name validation, so passing it on 2.44–2.53 would be rejected as an unknown flag.

Change

  • internal/git/version.go: bump the threshold in supportsAllowUnknownHookName from >= 2.44 to >= 2.54, and update the surrounding comments.

Behavior now:

  • < 2.54 — flag omitted (no unknown-flag errors on older git).
  • >= 2.54 — flag included; required to allow non-native hook names like pre-av-pr/pre-av-sync.

If version detection fails, we still include the flag so modern git keeps working.

Test plan

  • go build ./...
  • go tool golangci-lint run ./internal/git/... ./cmd/av/...
  • go test --vet=all ./internal/git/... ./cmd/av/...
  • Locally upgraded to git 2.54.0 and can confirm av sync now invokes the pre-av-sync hook instead of failing with unknown hook event.
  • CI green

The flag was introduced in git 2.54 (not earlier), so only include it
when the detected version is >= 2.54. Older gits reject unrecognized
flags, so we must not pass it there.
@jainankit jainankit requested a review from a team as a code owner April 22, 2026 20:39
@aviator-app
Copy link
Copy Markdown
Contributor

aviator-app Bot commented Apr 22, 2026

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged using Aviator.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

@aviator-app
Copy link
Copy Markdown
Contributor

aviator-app Bot commented Apr 22, 2026

✅ FlexReview Status

Common Owner: aviator-co/engineering (expert-load-balance assignment)
Owner and Assignment:

  • aviator-co/engineering (expert-load-balance assignment)
    Owned Files
    • 🔒 internal/git/version.go

Review SLO: 7 business hours if PR size is <= 200 LOC for the first response.

@aviator-app aviator-app Bot requested a review from davi-maciel April 22, 2026 20:39
@aviator-app aviator-app Bot merged commit dcd5c60 into master Apr 22, 2026
5 checks passed
@aviator-app aviator-app Bot deleted the fix-hooks-threshold-2.54 branch April 22, 2026 20:40
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Git version check logic for the --allow-unknown-hook-name flag, changing the threshold from version 2.44 to 2.54. Review feedback suggests that 2.54 is a typo for 2.45, which is the version where the flag was actually introduced; using 2.54 would cause the flag to be incorrectly omitted on versions 2.45 through 2.53, potentially leading to hook execution failures.

Comment thread internal/git/version.go
Comment on lines +44 to +45
// 2.54+, which introduced it and simultaneously began rejecting non-native
// hook names without it. Older gits don't recognize the flag.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The version 2.54 appears to be a typo for 2.45. Git 2.44 is the current stable release, and the --allow-unknown-hook-name flag was introduced in Git 2.45. Using 2.54 will cause the flag to be omitted on versions 2.45 through 2.53, which will likely lead to hook execution failures on those versions due to strict hook name validation.

Suggested change
// 2.54+, which introduced it and simultaneously began rejecting non-native
// hook names without it. Older gits don't recognize the flag.
// 2.45+, which introduced it and simultaneously began rejecting non-native
// hook names without it. Older Git versions don't recognize the flag.

Comment thread internal/git/version.go
return true
}
return major > 2 || (major == 2 && minor >= 44)
return major > 2 || (major == 2 && minor >= 54)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

As noted above, the minor version threshold should be 45 instead of 54 to correctly support Git 2.45+.

Suggested change
return major > 2 || (major == 2 && minor >= 54)
return major > 2 || (major == 2 && minor >= 45)

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