@@ -46,9 +46,33 @@ tasks:
4646 - git cliff --latest --output CHANGELOG.md --prepend
4747
4848 changelog:setup-hook :
49- desc : Setup git hook to automatically update changelog on commit
49+ desc : Setup git hook to automatically update and commit changelog
5050 cmds :
5151 - echo '#!/bin/bash' > .git/hooks/post-commit
52- - echo 'git cliff --output CHANGELOG.md' >> .git/hooks/post-commit
52+ - echo 'git cliff --output CHANGELOG.md' >> .git/hooks/post-commit
53+ - echo 'git add CHANGELOG.md' >> .git/hooks/post-commit
54+ - echo 'git diff --cached --quiet || git commit --amend --no-edit' >> .git/hooks/post-commit
5355 - chmod +x .git/hooks/post-commit
54- - echo "Git hook installed! Changelog will update automatically on each commit."
56+ - echo "Git hook installed! Changelog will update and amend automatically on each commit."
57+
58+ changelog:setup-pre-commit :
59+ desc : Setup pre-commit hook to update changelog before committing
60+ cmds :
61+ - echo '#!/bin/bash' > .git/hooks/pre-commit
62+ - echo 'git cliff --output CHANGELOG.md' >> .git/hooks/pre-commit
63+ - echo 'git add CHANGELOG.md' >> .git/hooks/pre-commit
64+ - chmod +x .git/hooks/pre-commit
65+ - echo "Pre-commit hook installed! Changelog will update automatically before each commit."
66+
67+ changelog:remove-hooks :
68+ desc : Remove changelog git hooks
69+ cmds :
70+ - rm -f .git/hooks/post-commit .git/hooks/pre-commit
71+ - echo "Git hooks removed."
72+
73+ changelog:commit :
74+ desc : Update changelog and commit it
75+ cmds :
76+ - git cliff --output CHANGELOG.md
77+ - git add CHANGELOG.md
78+ - git commit -m "docs : update changelog" || echo "No changes to commit"
0 commit comments