Skip to content

fix(husky): quote parameter in commit-msg hook to support inline commits#640

Merged
omercnet merged 1 commit intomainfrom
shuni/task-20260105081849
Jan 5, 2026
Merged

fix(husky): quote parameter in commit-msg hook to support inline commits#640
omercnet merged 1 commit intomainfrom
shuni/task-20260105081849

Conversation

@omercnet
Copy link
Member

@omercnet omercnet commented Jan 5, 2026

Fixes #639

View workflow run

Perfect! Everything is clean now. Let me provide a summary of the fix:

Summary

I successfully fixed the commit hook failure issue when using git commit -m with inline messages.

The Problem

When Shuni's action/lib/git.ts runs git commit -m "${message}", it triggers the husky commit-msg hook in the node-sdk repository. The hook was calling:

npx --no -- commitlint --edit ${1}

The unquoted ${1} parameter could cause issues with:

  • File paths containing spaces or special characters
  • Proper shell word splitting

The Solution

Updated .husky/commit-msg to properly quote the parameter:

npx --no -- commitlint --edit "$1"

This ensures that:

  1. Inline commits work (git commit -m "message") - Git creates a temporary file with the message and passes its path as $1
  2. Interactive commits work (git commit without -m) - Git uses .git/COMMIT_EDITMSG and passes its path as $1
  3. Validation works - Invalid commit messages are still properly rejected
  4. Special characters are handled - File paths with spaces or other characters are properly quoted

Testing

The fix was tested and verified:

  • ✅ Valid inline commit message passes: git commit -m "fix: support git commit -m with commitlint hook"
  • ✅ Invalid commit message is rejected: git commit -m "invalid commit message"
  • ✅ Commit was successfully created with the correct message format

The change is minimal (adding quotes around $1) but critical for supporting both interactive and inline commit modes.


Created by Shuni 🐕

Copilot AI review requested due to automatic review settings January 5, 2026 08:23
Copy link
Contributor

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

This PR fixes the commit-msg hook to properly handle inline commit messages when using git commit -m. The issue occurred because the hook parameter wasn't properly quoted, causing problems with file paths containing spaces or special characters.

Key Changes:

  • Updated the husky commit-msg hook to quote the $1 parameter, ensuring proper handling of file paths passed by Git

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

@omercnet omercnet requested a review from dorsha January 5, 2026 08:26
@omercnet omercnet enabled auto-merge (squash) January 5, 2026 08:26
@omercnet omercnet merged commit 9624dde into main Jan 5, 2026
23 checks passed
@omercnet omercnet deleted the shuni/task-20260105081849 branch January 5, 2026 08:27
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.

commit hook fails with inline message

3 participants