Created
December 16, 2015 00:23
-
-
Save organisciak/8df19f54240eb37b599a to your computer and use it in GitHub Desktop.
githook to convert iPython README to Markdown
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
READPY=$(git log --name-only HEAD^.. | grep "^README.ipynb$") | |
READMD=$(git log --name-only HEAD^.. | grep "^README.md$") | |
if [ -n "$READPY" ] && [ -z "$READMD" ]; then | |
echo "It looks like a new README was committed, appending a Markdown version" | |
ipython nbconvert --to markdown README.ipynb | |
# Adding this file doesn't work in pre-commit hooks, which is | |
# why we're appending post-commit | |
git add README.md | |
# We don't want to run this hook again after appending | |
git commit --amend -C HEAD --no-verify | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why not simply generate the file
pre-commit
and stage? Becausegit add
does not actually stage inpre-commit
scripts. This is why the script checks post-commit and steps back, amending the commit.