Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions hack/git/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,4 @@ To rename your current branch, run:

Replace <NEW-BRANCH-NAME> with a valid branch name and try again."
exit 1
fi

exit 0
fi
14 changes: 14 additions & 0 deletions hack/git/hooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e
LC_ALL=C

echo "Before pushing commits, ensure you've run the required make commands:"
echo " - make generate"
echo " - make imports"
read -r -p "Have you run all required make commands? [y/N] " run_make_commands
if [[ ! "${run_make_commands}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Elaborating on the second point:

  • Executing all the required make targets as part of the script
  • Running git status --porcelain to detect modified or untracked files
  • Fail and ask to run the required make commands and keep the local repo clean after commits.

PS: I always have some modified/untracked files on my local, so I would not prefer this flow. But a suggestion.
I believe asking every time during push is fine.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I didn't want to have to maintain all the required make commands within the script hence this implementation just being a nag vs total automation.

echo "Commit aborted. Run the required make commands and try again."
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

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

This message says "Commit aborted" but this is a pre-push hook; it should say "Push aborted" (or similar) to avoid confusion.

Suggested change
echo "Commit aborted. Run the required make commands and try again."
echo "Push aborted. Run the required make commands and try again."

Copilot uses AI. Check for mistakes.
exit 1
Comment on lines +8 to +11
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

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

pre-push hooks receive the list of refs to push on stdin. Using read -p without redirecting will read from that stdin (consuming a ref line) instead of from the user, which can cause the hook to abort pushes unexpectedly (often every time). Read the confirmation from /dev/tty (or similar) and/or guard for non-interactive environments so pushes from automation/IDEs don't hang or fail due to EOF.

Suggested change
read -r -p "Have you run all required make commands? [y/N] " run_make_commands
if [[ ! "${run_make_commands}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo "Commit aborted. Run the required make commands and try again."
exit 1
# Only prompt when an interactive terminal is available.
if [ -t 0 ] || [ -t 1 ]; then
# Read from /dev/tty so we don't consume Git's stdin (the list of refs).
if ! read -r -p "Have you run all required make commands? [y/N] " run_make_commands </dev/tty; then
# If we cannot read from the terminal, allow the push to proceed.
exit 0
fi
if [[ ! "${run_make_commands}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo "Commit aborted. Run the required make commands and try again."
exit 1
fi

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's comment here makes sense to me, but we're probably fine without it. I can't imagine when/why we'd want automation pushing to this repo.

fi

exit 0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Did you mean to put this here? Asking since you removed it from the existing pre-commit hook.

Loading