Last active
August 29, 2015 14:01
-
-
Save miku/111bb2c029ffe89475d7 to your computer and use it in GitHub Desktop.
Git pre-commit hook, taking a screenshot of a single webpage
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 | |
HOMEPAGE=http://localhost:5000 | |
SCREENIE_DIR=$(pwd)/screenshots | |
HEAD=$(git rev-parse HEAD) | |
if [[ "$OSTYPE" == "darwin"* ]]; then | |
RESPONSE=$(curl --write-out %{http_code} --silent --output /dev/null "$HOMEPAGE") | |
if [[ "$RESPONSE" == 200 ]]; then | |
mkdir -p "$SCREENIE_DIR" | |
OUTPUT="$(date +'%s')-$HEAD.png" | |
webkit2png --dir "$SCREENIE_DIR" -o "$OUTPUT" "$HOMEPAGE" | |
git add "$SCREENIE_DIR" | |
exit 0 | |
else | |
echo "Stopping. Please start the server manually," | |
echo "so we can take our photograph. Or run 'git commit --no-verify'" | |
echo "$HOMEPAGE response was $RESPONSE" | |
exit 1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment