qoomon / git-conventional-commits

Git Conventional Commits Util to generate Semantic Version and Markdown Change Log and Validate Commit Messag
https://short.qoo.monster/Conventional-Commits
GNU General Public License v3.0
357 stars 38 forks source link

git-conventional-commits init [options] doesn't include [options] in commit-msg hook #156

Open jmcmahon1999 opened 3 months ago

jmcmahon1999 commented 3 months ago

When calling git-conventional-commits init [options] in a new repository, the options are not appended to the generated commit message hook.

For example: In an empty repo I use git-conventional-commits init -c ./.git-conventional-commits.yaml, as I want my config file to be a hidden file.

The commit message hook the command generates looks like this:

#!/bin/sh

if command -v git-conventional-commits > /dev/null 2>&1
then
  # fix for windows systems
  PATH="/c/Program Files/nodejs:$HOME/AppData/Roaming/npm/:$PATH"
  git-conventional-commits commit-msg-hook "$1"
fi

I would expect it to look like this:

#!/bin/sh

if command -v git-conventional-commits > /dev/null 2>&1
then
  # fix for windows systems
  PATH="/c/Program Files/nodejs:$HOME/AppData/Roaming/npm/:$PATH"
  git-conventional-commits commit-msg-hook "$1" -c ./.git-conventional-commits.yaml  #Appended args here.
fi

It seems that this should also happen if .pre-commit-config.yaml exists in the repo and defines the args: option.

qoomon commented 3 months ago

Good point.

What do you mean by

It seems that this should also happen if .pre-commit-config.yaml exists in the repo and defines the args: option.

jmcmahon1999 commented 3 months ago

It's not core to this issue to be honest. But I was just previously adding the commit-msg hook with pre-commit using the following config:

repos:
- repo: https://github.com/qoomon/git-conventional-commits
  rev: v2.6.7
  hooks:
    - id: conventional-commits
      args: ['-c', '.git-conventional-commits.yaml']

But now that I think about it, being able to install the hook with both pre-commit and git-conventional-commits init doesn't make sense.