git-cliff
git-cliff copied to clipboard
Make git short sha (SHA-1) available
Is there an existing issue or pull request for this?
- [x] I have searched the existing issues and pull requests
Feature description
I want to generate links to the gitlab webinterface for commits like [{{ commit.id }}](https://gitlab.something.com/user/project/commits/{{ commit.id }}) but the full id is quite long and I rather use the short sha as the git cli provides it...
Desired solution
I would like to be able use commit.short_id or something next to commit.id in templates
Alternatives considered
A template filter that converts the long sha into a short one. This will not work as expected because git does some magic to adapt the length of the short sha so that there is low chance on collisions.
Additional context
No response
Thanks for opening your first issue at git-cliff! Be sure to follow the issue template! ⛰️
You can use the truncate filter for this, e.g.
{{ previous.commit_id | truncate(length=7, end="") }}
While truncate will help it it technically not the same...
From the git book:
Git can figure out a short, unique abbreviation for your SHA-1 values. If you pass --abbrev-commit to the git log command, the output will use shorter values but keep them unique; it defaults to using seven characters but makes them longer if necessary to keep the SHA-1 unambiguous: