-
Notifications
You must be signed in to change notification settings - Fork 105
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
feat: git hooks integration #106
Conversation
To run git-cz on `prepare-commit-msg` you can basically follow this instruction (https://github.com/commitizen/cz-cli#optional-running-commitizen-on-git-commit) but usestreamich's `git-cz` instead of `cz-conventional-changelog`. ✅ Closes: #79
I would really appreciate this feature. Is there anything that prevents it from being merged? Workaround in the mean time
|
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.
Thanks! This is very nice.
@@ -31,7 +33,7 @@ const main = async () => { | |||
params[arg] = true; | |||
} | |||
|
|||
const {'dry-run': isDryRun, ...passThroughParams} = params; | |||
const {'dry-run': isDryRun, hook: isHook, ...passThroughParams} = params; |
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.
We have --dry-run
flag that prints the message to STDOUT, and now we have --hook
flag that will write the message to /.git/COMMIT_EDITMSG
, and by default it would execute git commit ...
. I'm thinking maybe we could unify all of those into a single argument:
git-cz --output=git
git-cz --output=stdout
git-cz --output=file --file=/.git/COMMIT_EDITMSG
git-cz --output=file --file=/.git/MERGE_MSG
git-cz --output=file --file=/.git/SQUASH_MSG
lib/cli.js
Outdated
* @see https://github.com/streamich/git-cz/issues/79 | ||
*/ | ||
if (isHook) { | ||
const commitMsgFile = getGitRootDir() + '/.git/COMMIT_EDITMSG'; |
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 it be also useful to support /.git/MERGE_MSG
and /.git/SQUASH_MSG
?
🎉 This PR is included in version 4.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I added git hooks support so you can run
git-cz
onprepare-commit-msg
.To make it work, you should update
.git/hooks/prepare-commit-msg
with following code:Same works with Husky:
Closes #79