How to add commit trailer based on commit type selected
krupis opened this issue Β· comments
Hello. I use Gitlab built-in feature (glab
) to generate Changelogs for my projects based on Commit trailer messages as described here:
https://docs.gitlab.com/ee/user/project/changelogs.html
In order for glab
to detect commits, each commit needs to have a commit trailer. My commit example:
git commit -m "fixed voltage measurement issue" --trailer "Changelog: fixed"
The following commit with a trailer will then show up in the Gitlab as shown below:
And when I generate the changelog, it will look something like:
## 1.0.2-5-g796eb48
(2024-01-25)
### fixed (1 change)
- [fixed voltage measurement issue](testing/universal-testboard-v3@825b7b5474216ab7abc84af033b417a766952e8e) ([merge request](testing/universal-testboard-v3!1))
Since I am making all commit messages and commit trailers by hand, this method is very sensitive to human error. For example if I make typo when writing a commit trailer, the glab
will not detect the commits.
I was hoping to use better-commits
to automate this process and ensure each commit is tagged with appropriate commit trailer based on selected commit type.
For example, I have a list of commit types:
"commit_type": {
"enable": true,
"initial_value": "feat",
"infer_type_from_branch": true,
"append_emoji_to_label": false,
"append_emoji_to_commit": false,
"options": [
{
"value": "feat",
"label": "feat",
"hint": "A new feature",
"emoji": "β¨"
},
{
"value": "fix",
"label": "fix",
"hint": "A bug fix",
"emoji": "π"
},
{
"value": "docs",
"label": "docs",
"hint": "Documentation only changes",
"emoji": "π"
},
{
"value": "test",
"label": "test",
"hint": "Adding missing tests or correcting existing tests",
"emoji": "π¨"
},
{
"value": "ci",
"label": "ci",
"hint": "Changes to our CI configuration files and scripts",
"emoji": "π€"
},
{
"value": "",
"label": "none"
}
]
},
Is there a possibility to append a trailer to commit message based on selected commit type? For example, if I select feat
, I want to automatically append Changelog: added
as my Commit trailer.
If I select fix
, I want to append Changelog: fixed
and etc...
Thanks in advance!
Hey thanks for writing up this issue! - I've seen trailers on Github PRs like "Co-Authored by X" but had no idea they were their own flag on git commit, pretty cool!
Yeah I think this makes sense and is easy to add to the project.
π This issue has been resolved in version 1.9.0 π
The release is available on:
Your semantic-release bot π¦π