Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
28 changes: 28 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Commit Message Lint

on:
pull_request:
types: [opened, synchronize, edited]

jobs:
lint-commits:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'

- name: Install dependencies
run: npm install

- name: Lint commit messages
run: |
git fetch origin main
COMMITS=$(git log origin/main..HEAD --pretty=format:"%H")
echo "$COMMITS" | while read commit; do
npx commitlint --from=$commit --to=$commit --verbose
done
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ command_output.log
# Properties
src/main/environment/1097_local.properties
src/main/environment/common_local.properties

node_modules/
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test
4 changes: 4 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install cz
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify the Commitizen usage in prepare-commit-msg hook

The current implementation runs Commitizen without passing the commit message file as a parameter, which may not work as expected. Typically, a prepare-commit-msg hook receives parameters ($1, $2, $3) that should be passed to the tool that modifies the commit message.


🏁 Script executed:

#!/bin/bash
# Check Commitizen documentation for proper usage in Git hooks
echo "Checking standard prepare-commit-msg hooks for Commitizen..."
curl -s https://github.com/commitizen/cz-cli/blob/master/README.md | grep -A 10 "prepare-commit-msg"

echo -e "\nStandard prepare-commit-msg hooks typically pass parameters:"
echo "Example: npx --no-install cz --hook || true"
echo "or: exec < /dev/tty && npx cz --hook || true"

echo -e "\nCurrent implementation:"
cat .husky/prepare-commit-msg

Length of output: 65842


Ensure the Husky hook invokes Commitizen with the --hook flag and an interactive TTY

The current .husky/prepare-commit-msg just runs

npx --no-install cz

but Commitizen’s hook mode requires the --hook argument and a TTY for interactivity. Please update it to something like:

 File: .husky/prepare-commit-msg
-------------------------------------------------------------------
 #!/usr/bin/env sh
 . "$(dirname -- "$0")/_/husky.sh"
-
-npx --no-install cz
+exec < /dev/tty && npx --no-install cz --hook || true
  • exec < /dev/tty attaches the hook to your terminal for prompts
  • --hook tells CZ to process the prepare-commit-msg hook parameters
  • || true prevents hook failures from blocking commits if needed

3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
Copy link
Member

Choose a reason for hiding this comment

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

};
Loading