Last active
August 29, 2015 14:27
-
-
Save rrdelaney/f587ec22133f12fdfe4c to your computer and use it in GitHub Desktop.
Rebaseify!
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
#!/bin/bash | |
if [[ $# -eq 0 ]] ; then | |
echo "Rebasify!" | |
echo "Usage" | |
echo "rebaseify start" | |
echo " generates commit log for editing" | |
echo "" | |
echo "rebaseify finish" | |
echo " rebases on the edited commit log" | |
fi | |
force='' | |
if test "x$1" = "x-f"; then | |
force='-f' | |
shift | |
fi | |
commits=$(git log --pretty=format:'"%H": {"author": {"name": "%an"}, "date": "%cd"},') | |
filter=' | |
export GIT_COMMITER_DATE=$(node -p "require(\"./../../commits\")[\"$GIT_COMMIT\"].date") | |
export GIT_AUTHOR_DATE=$(node -p "require(\"./../../commits\")[\"$GIT_COMMIT\"].date") | |
export GIT_AUTHOR_NAME=$(node -p "require(\"./../../commits\")[\"$GIT_COMMIT\"].author.name") | |
' | |
if [[ $1 = "start" ]] ; then | |
printf "{\n${commits%?}\n}\n" > commits.json | |
fi | |
if [[ $1 = "finish" ]] ; then | |
git filter-branch $force --env-filter "$filter" -- "$(git rev-parse --abbrev-ref HEAD)" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment