Last active
February 25, 2019 15:06
-
-
Save saimn/67d7b2af5031a32dc9903be0d858616c to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
# | |
# Git pre commit hook which find the next PR number and replace occurences of | |
# GUESSPR in the changelog | |
files_modified=`git diff --cached --name-only --diff-filter=ACM` | |
if [[ $files_modified == *"CHANGES.rst"* ]]; then | |
ghurl="https://api.github.com/repos/astropy/astropy/issues?state=all&sort=created&direction=desc&per_page=1" | |
echo "Fetching PR number from $ghurl" | |
prnumber=$(curl -s $ghurl | \ | |
python -c "import sys, json; print(json.load(sys.stdin)[0]['number'] + 1)") | |
sed -i "s/GUESSPR/#$prnumber/" CHANGES.rst && echo "Wrote PR number :)" || echo "FAILED" | |
git add CHANGES.rst | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment