Skip to content

example for commit-msg hook#751

Closed
fengmk2 wants to merge 1 commit intomasterfrom
exmple-for-commit-msg
Closed

example for commit-msg hook#751
fengmk2 wants to merge 1 commit intomasterfrom
exmple-for-commit-msg

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Apr 20, 2026

Summary by CodeRabbit

  • Chores
    • Added development infrastructure for commit message hooks.

Copilot AI review requested due to automatic review settings April 20, 2026 07:16
@fengmk2 fengmk2 closed this Apr 20, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ede7796e-1b5e-4c98-b2a2-51ff15ce7c31

📥 Commits

Reviewing files that changed from the base of the PR and between aa93679 and a37a818.

📒 Files selected for processing (1)
  • .vite-hooks/commit-msg

📝 Walkthrough

Walkthrough

A new git commit-msg hook file is added to the .vite-hooks/ directory. The hook contains a simple echo command that outputs "commit-msg works" when executed, with no additional logic or error handling.

Changes

Cohort / File(s) Summary
Git Hook Configuration
.vite-hooks/commit-msg
Added new commit-msg hook with a basic echo statement for validation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A hook so small, a message so bright,
Echo-ing words through the git-hook night,
Commit-msg whispers, "I'm working just right!"
One tiny line, perfectly tight! ✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch exmple-for-commit-msg

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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 introduces a new commit-msg hook script that outputs a confirmation message. The review feedback suggests adding a shebang line to the script to specify the interpreter, which ensures the script is executed correctly and improves portability across different environments.

Comment thread .vite-hooks/commit-msg
@@ -0,0 +1 @@
echo "commit-msg works"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Shell scripts should include a shebang line (e.g., #!/bin/sh) to specify the interpreter. This ensures the script is executed by the correct shell and improves portability across different environments.

#!/bin/sh

echo "commit-msg works"

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.65%. Comparing base (aa93679) to head (a37a818).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #751   +/-   ##
=======================================
  Coverage   94.65%   94.65%           
=======================================
  Files          10       10           
  Lines         730      730           
  Branches      228      228           
=======================================
  Hits          691      691           
  Misses         36       36           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a .vite-hooks/commit-msg hook example intended to demonstrate that the commit-msg hook is being executed in the repo’s Vite+ (vp config) hook setup.

Changes:

  • Introduce a new commit-msg hook under .vite-hooks that prints a message during commits.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .vite-hooks/commit-msg
@@ -0,0 +1 @@
echo "commit-msg works"
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

The commit-msg hook currently just echoes a message. This will add noise to every commit and doesn't validate the commit message (it also ignores the commit message file path passed as $1). Consider either removing this hook from the default .vite-hooks set or replacing it with an actual commit message validation that reads $1 and exits non-zero on failure (and stays silent on success).

Suggested change
echo "commit-msg works"
#!/bin/sh
commit_msg_file="$1"
if [ -z "$commit_msg_file" ] || [ ! -f "$commit_msg_file" ]; then
echo "commit-msg: missing or invalid commit message file path." >&2
exit 1
fi
commit_msg=$(sed -n '/^[[:space:]]*#/d;/^[[:space:]]*$/d;1p' "$commit_msg_file")
if [ -z "$commit_msg" ]; then
echo "commit-msg: commit message must not be empty." >&2
exit 1
fi
exit 0

Copilot uses AI. Check for mistakes.
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