Ability append / prepend a prefix or a dynamic text on commit message
See original GitHub issueI have multiple projects with different Jira numbers. So in my project, I only want the user to commit a message following @commitlint/config-conventional rules.
I could not find anything on documentation that can help my case, is this possible using the setup below?
Expected Behavior
fix: bla bla bla
should pass but actual commit should be[ABCD-10] fix: bla bla bla
bla bla bla
should fail
[ABCD-10] bla bla bla
should fail
[ABCD-10 fix: bla bla bla
should fail
Current Behavior
fix: bla bla bla
passes but I’m unable to append my prefix before the commit pushes
Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
A way to prepend, append fixed or dynamic text
Steps to Reproduce (for bugs)
see below setup
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
// commitlint.config.js
module.exports = {
extends: ["@commitlint/config-conventional"],
};
Context
Your Environment
Executable | Version |
---|---|
commitlint --version |
9.1.1 |
git --version |
2.21.0 |
node --version |
v10.15.0 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Commit message templates - GitLab Docs
GitLab uses commit templates to create default messages for specific types of commits. These templates encourage commit messages to follow a particular ...
Read more >How to add Git's branch name to the commit message?
Here is my commit-msg script as an example: #!/bin/sh # # Automatically adds branch name and branch description to every commit message. #...
Read more >Prepending Your Git Commit Messages with User Story IDs
It's always a good practice to prepend your commit messages with something meaningful. For example, it is often common when working with project...
Read more >Change default title for pull request commits to not include PR id
Please provide a means to set a default commit message using static text and special variables which would provide dynamic values, such as...
Read more >CommitPrefix - IntelliJ IDEs Plugin
Helps you to insert the task number from current branch to the beginning of the commit message. Usage sample: Full Usage Documentation. Email....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@escapedcat thanks for taking the time. You are right, it is more likely scope for Husky or even Githooks. We can close.
I might have a unique use case. We have a couple of different projects and each project needs to have their own JIRA ticket, and not per commit. So for each project, I needed to append the same JIRA ID for all of the commits coming from the same project. Doing that, developers won’t need to do manual work of adding the same ticket id all the time. Meanwhile, we wanted to still have some rules in place to commit a message, so that you can’t push a commit without a type and subject. I have used
@commitlint/config-conventional
for the job.I am actually able to do this with the help of a shell script.
package.json
commit-hook.sh
since the shell script runs after commitlint it does not get checked and you can do push afterward without problem
for instance: if you commit
"fix: message"
passes the validation but when you do push, you’ll see Jira ticket prepended automatically to your commit messageJIRA:10 fix: message