Disable hook if commit message already starts with emoji
thdk opened this issue Β· comments
Description of the problem
Context: automating bumping versions of node packages
β― gitmoji -i
β― git commit -a -m "π Bump version to $npm_package_version"
? Choose a gitmoji: π - Release / Version tags.
? Enter the commit title [18/48]: π Bump version to 0.1.0
? Enter the commit message:
[feature/abc 468583a] π π Bump version to 0.1.0
2 files changed, 4 insertions(+), 4 deletions(-)
Could we detect in the prepare commit message hook that the commit message already contains an emoji and if so skip the emoji prompt?
Or still show the prompt but preselect the result with the emoji from the commit message?
Solution
const commit = (options: CommitOptions): Function => {
if (options.mode === COMMIT_MODES.HOOK) {
registerHookInterruptionHandler()
if (options.message?.startsWith(anyEmoji)) {
commit(options)
else {
return cancelIfNeeded().then(() => promptAndCommit(options))
}
}
return promptAndCommit(options)
}
Alternatives
git commit --no-verify
doesn't seem to prevent the gitmoji hook.
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue requesting the same feature.
Hey!
Thanks for opening the issue, I think it makes sense but we should probably aim to support the --no-verify
option instead of doing this "magic" of skipping the hook if the emoji is provided already
Feel free to raise a Pull Request! ππΌ
Hey! So I took at stab at this and found out it's not possible to use --no-verify
for the prepare-commit-msg
hook (it is ignored) as mentioned in the docs
I implemented the PR as an alternative solution to this.
We might want to explore switching from prepare-commit-msg
to commit-msg
to support --no-verify
Released in v8.3.0
π https://github.com/carloscuesta/gitmoji-cli/releases/tag/v8.3.0