-
Notifications
You must be signed in to change notification settings - Fork 25.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: add a commit-msg git hook to check commit messages #22969
Conversation
The commit command will fail if the commit message header does not follow the Angular convetions as defined in /CONTRIBUTING.md. You can force the commit by adding the `--no-verify` option. NOTE: You should remove all unused hooks (in <angular>/.git/hooks) before running `yarn` so that husky hooks are installed correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start. Thanks.
package.json
Outdated
@@ -23,10 +23,12 @@ | |||
"preinstall": "node tools/yarn/check-yarn.js", | |||
"postinstall": "yarn update-webdriver && node ./tools/postinstall-patches.js", | |||
"update-webdriver": "webdriver-manager update --gecko false $CHROMEDRIVER_VERSION_ARG", | |||
"check-env": "gulp check-env" | |||
"check-env": "gulp check-env", | |||
"commitmsg": "./scripts/git/commit-msg.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would that be ok on windows ?
do we need node ./scripts/git/commit-msg.js
?
@ocombe do you know ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't try it, but I am almost sure you need node
😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please @gkalpak it would really help to have someone confirms what works on win
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am afk until Sunday evening. I can confirm then (since you don't trust my "almost-sureness" 😛).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't work without node:
git commit -m "jlkjnljn"
husky > npm run -s commitmsg (node v8.9.2)
'.' n’est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
husky > commit-msg hook failed (add --no-verify to bypass)
if I add node it works:
git commit -m "jlkjnljn"
husky > npm run -s commitmsg (node v8.9.2)
INVALID COMMIT MSG: "jlkjnljn"
=> ERROR: The commit message does not match the format of '<type>(<scope>): <subject>' OR 'Revert: "type(<scope>): <subject>"'
Check CONTRIBUTING.md at the root of the repo for more information.
husky > commit-msg hook failed (add --no-verify to bypass)
the good news is that it also works with GUI apps like git kraken, which is awesome :)
package.json
Outdated
@@ -23,10 +23,12 @@ | |||
"preinstall": "node tools/yarn/check-yarn.js", | |||
"postinstall": "yarn update-webdriver && node ./tools/postinstall-patches.js", | |||
"update-webdriver": "webdriver-manager update --gecko false $CHROMEDRIVER_VERSION_ARG", | |||
"check-env": "gulp check-env" | |||
"check-env": "gulp check-env", | |||
"commitmsg": "./scripts/git/commit-msg.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't try it, but I am almost sure you need node
😁
package.json
Outdated
}, | ||
"dependencies": { | ||
"core-js": "^2.4.1", | ||
"husky": "^0.14.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a devDependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep it should I thought It was there. (rant: why doesn't yarn understand --save-dev
???)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should upgrade to husky rc because there are some bug in this version, and the new version have a separate config for hooks instead of config in script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why doesn't yarn understand
--save-dev
You have to speak in its language (--dev
) if you want it to understand you 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I ended up doing but obviously I did it wrong. But isn't it kind of stupid that --save-dev
1) is not understood 2) does not even print a warning ? Fragmentation sucks !
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
I've updated the PR to add husky as a dev dep, and to add |
Excellent Olivier, Thanks !! |
merge-assistance:
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The commit command will fail if the commit message header does not follow the
Angular conventions as defined in /CONTRIBUTING.md.
You can force the commit by adding the
--no-verify
option.NOTE:
You should remove all unused hooks (in /.git/hooks) before running
yarn
so that husky hooks are installed correctly.The idea is to merge this one first and then I can work on the formatting hook to be merged after a few days (when we get feedback about how this one work for everybody).
Exemple output (success/fail)