git-cliff
git-cliff copied to clipboard
[Question] including the absolute latest commit into the changelog
I've been experimenting with the possibility of including the absolute latest commit into the changelog, by running git-cliff
through Docker on a post-commit
Git hook like below:
docker run -t -v "$(pwd)":/app orhunp/git-cliff:latest -o CHANGELOG.md &&
git add CHANGELOG.md && \
# disables and re-enables post-commit hook to avoid infinite loop
# for some reason, --no-verify and HUSKY=0 don't work
chmod -x .husky/post-commit
git commit --amend
chmod +x .husky/post-commit
But this hacky solution comes with a flaw, the hash of the latest commit is different from the one displayed on the changelog
I also noticed that git-cliff
's changelog doesn't use this, only changes between releases are displayed
Is this something feasible?
Hello!
This is like a 🐔-🥚 problem.
There is --with-commit
flag for this use-case. It makes it possible to add custom commit messages to the changelog.
commit_msg="chore(release): update CHANGELOG.md for 1.0.0"
git cliff --with-commit "$commit_msg" -o CHANGELOG.md
git add CHANGELOG.md && git commit -m "$commit_msg"
But still, you won't be able to get the hash for the latest commit with this method. However, for what it's worth, I committed d453d4cbebbb607ff7dbe530542802e8ca60b585 which makes it possible to specify the SHA.
I also tried your solution and worked fine for me (except the same issue):
git-cliff -o CHANGELOG.md && git add CHANGELOG.md
chmod -x .git/hooks/post-commit
git commit --amend
chmod +x .git/hooks/post-commit
There isn't any other good way to achieve this yet I would say. Let me know if you find a solution!