git-conventional-commits icon indicating copy to clipboard operation
git-conventional-commits copied to clipboard

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

Open jmcmahon1999 opened this issue 1 year ago • 2 comments

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.

jmcmahon1999 avatar May 21 '24 10:05 jmcmahon1999

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.

qoomon avatar May 21 '24 11:05 qoomon

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.

jmcmahon1999 avatar May 24 '24 11:05 jmcmahon1999