Skip to content

chore: enforce Go formatting with make fmt and pre-push hook#124

Merged
matt-dz merged 3 commits intomainfrom
matt-dz/format-files
Mar 18, 2026
Merged

chore: enforce Go formatting with make fmt and pre-push hook#124
matt-dz merged 3 commits intomainfrom
matt-dz/format-files

Conversation

@matt-dz
Copy link
Copy Markdown
Collaborator

@matt-dz matt-dz commented Mar 18, 2026

Summary

  • Updated AGENTS.md Code Style section to emphasize that make fmt must always be run after making any edits
  • Added fmt target to the Makefile (go fmt ./...)
  • Applied go fmt formatting fixes to allowedsymbols/symbols_internal.go
  • Added a hooks/pre-push hook that blocks pushes containing unformatted Go files

How the pre-push hook works

The hook leverages the existing Datadog global git hooks infrastructure (/usr/local/dd/global_hooks/), which is configured for all Datadog engineers via core.hooksPath. When you run git push:

  1. Git invokes the global pre-push hook
  2. The global hook delegates to run-local-hooks, which automatically discovers and executes hooks in the repo's hooks/ directory
  3. Our hooks/pre-push runs gofmt -l . to find any unformatted Go files
  4. If any are found, the push is blocked with a message listing the offending files and directing the developer to run make fmt

No per-repo setup is required — it works out of the box for anyone with the standard Datadog git hooks configured.

Test plan

  • Verify make fmt runs successfully
  • Verify hook passes when all files are formatted
  • Verify hook blocks push and lists unformatted files when formatting is off
  • Confirm CI passes

🤖 Generated with Claude Code

@matt-dz matt-dz marked this pull request as ready for review March 18, 2026 18:35
@matt-dz matt-dz enabled auto-merge March 18, 2026 18:37
matt-dz and others added 2 commits March 18, 2026 14:52
Adds a pre-push hook that checks all Go files are properly formatted
before allowing a push. Works out of the box via dd-git-hooks
global hooks infrastructure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matt-dz matt-dz changed the title chore: emphasize make fmt in AGENTS.md and add Makefile target chore: enforce Go formatting with make fmt and pre-push hook Mar 18, 2026
@matt-dz matt-dz added this pull request to the merge queue Mar 18, 2026
Merged via the queue into main with commit 3e5cae4 Mar 18, 2026
30 of 31 checks passed
@matt-dz matt-dz deleted the matt-dz/format-files branch March 18, 2026 19:04
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