qiskit.org
qiskit.org copied to clipboard
Setup commitlint
commitlint checks if your commit messages meet the conventional commit format.
It's a suggested add-on in newer Nuxt versions.
This is not decoration. It is not related to aesthetics. I think this could be code-quality
I'm going to do the best I can with this. However, commitlint relies on hooks to enforce the commit message meets the format criteria. Specifically, it relies on the commit-msg hook.
Typically, this would be enforced either by the developer manually adding the hook to their development environment (no guarantee it'll be followed), or by using a hook library like Husky.
- One can't easily use their own Git Hook templates or manually-added hooks, along with Husky.
I recommend Husky, since it's a vetted library that's widely used. However, I can at least provide the configuration files in a PR for now.
I'd like to ask... why use commitlint to enforce the format? What tools are leveraging it?
I ask, because I myself do use semantic-release to auto-tag my repo, and auto-generate my Changelog file.
Semantic Release relies on reading in commit messages written in a standard format, such as conventional commit, among others.
I'm going to do the best I can with this. However, commitlint relies on hooks to enforce the commit message meets the format criteria. Specifically, it relies on the
commit-msghook.Typically, this would be enforced either by the developer manually adding the hook to their development environment (no guarantee it'll be followed), or by using a hook library like Husky.
- One can't easily use their own Git Hook templates or manually-added hooks, along with Husky.
I recommend Husky, since it's a vetted library that's widely used. However, I can at least provide the configuration files in a PR for now.
Git Hooks
We can either ask devs to create a commit-msg git hook via
mkdir -p .git/hooks/ && \
echo '#!/bin/sh
npx --no-install commitlint --edit \"$1\"' > .git\hooks\commit-msg
Side note: On windows, I ran into an error when I tried to commit.
SyntaxError: Invalid or unexpected token
...
This was because the file was created in UTF-16 BE encoding. It should be saved as UTF-8.
Husky
Install husky:
npm i -D husky
Then, we run husky's install command and set up the commit-msg hook.
npx husky install && npx husky add .husky/commit-msg 'npx --no-install commitlint --edit "$1"'
If you read the output, it should recommend installing pinst as well, and add some additional package.json scripts.
npm i -D pinst
And add to the package.json
"scripts": {
"postinstall": "husky install",
"prepublishOnly": "pinst --disable",
"postpublish": "pinst --enable"
},
I can include any Husky stuff as part of the Pull Request, if that's the right decided.
Thanks a lot @shmolf for the help!
We're currently awaiting the results of an internal discussion about the purpose of enforcing a certain structure in our commit messages.
Thanks a lot @shmolf for the help!
We're currently awaiting the results of an internal discussion about the purpose of enforcing a certain structure in our commit messages.
It's not an easy decision, especially if there's already a current practice by devs to use their own hooks, or other concerns. If you have any questions, please feel free to ask.
We didn't see the need as a team to setup commitlint.