-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
By (optionally) changing the template to skip commit hashes for unreleased commits, it becomes possible to integrate Jilu in a post-commit workflow that automatically amends your commits with the updated changelog.
Without this feature, the amended changes will cause the commit hash to change, and thus you'll have to update the change log again, going into an endless loop.
This is already possible, but requires you to add a custom template to your CHANGELOG.md with these parts updated/removed:
{%- for change in unreleased.changes -%}
- {{ change.type }}: {{ change.description }} ([`{{ change.commit.short_id }}`])
{% endfor %}
{% for change in unreleased.changes %}
[`{{ change.commit.short_id }}`]: {{ url }}/commit/{{ change.commit.id }}
{%- endfor -%}
You can then use a .git/hooks/post-commit hook such as this one:
#!/bin/sh
# Update CHANGELOG.md with latest commit message.
jilu | sponge CHANGELOG.md
# No changes detected.
git diff --quiet --exit-code CHANGELOG.md && exit 0
git add CHANGELOG.md
# We have to manually disable this hook or else we'll get into a loop. There is
# no way to disable "post-commit" hooks using the Git CLI.
gitdir="$(git rev-parse --git-dir)"
hook="$gitdir/hooks/post-commit"
[ -x "$hook" ] && chmod -x "$hook"
git commit --no-verify --amend --no-edit --quiet
chmod +x "$hook"
echo "$(git rev-parse --short HEAD): CHANGELOG.md update amended"Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request