Created
September 23, 2019 18:15
-
-
Save haggen/5e0422daf48c493556242d26c821f9ec to your computer and use it in GitHub Desktop.
Random post-commit hook saved for later reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euxo pipefail | |
last-commited-files() { | |
git diff-tree --no-commit-id --name-only -r HEAD | |
} | |
message="Bumping" | |
last-commited-files | while read file; do | |
scripts/find-toc "$file" | |
done | sort -u | while read toc; do | |
if git diff-index --quiet HEAD "$toc" >/dev/null 2>&1; then | |
git stash push --quiet --message "$message" -- "$toc" #>/dev/null 2>&1 | |
fi | |
scripts/bump "$toc" patch | |
git add "$toc" #>/dev/null 2>&1 | |
git commit --amend --no-edit #>/dev/null 2>&1 | |
stash="$(git stash list | grep "$message" | cut -d: -f1)" | |
if test -n "$stash"; then | |
git stash pop --quiet "$stash" #>/dev/null 2>&1 | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment