Last active
January 4, 2016 14:39
-
-
Save infotexture/8635931 to your computer and use it in GitHub Desktop.
Sample Git `pre-commit` hook to build DITA output before committting and reject the changes if build fails
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/sh | |
# | |
# Get the absolute path of the `.git/hooks` directory | |
export GIT_HOOKS=`cd "\`dirname "\\\`readlink "$0" || echo $0\\\`"\`" && pwd` | |
# Set the absolute path of the build directory | |
export BUILD_FILES="$GIT_HOOKS/../../build-files/" | |
# Set the absolute path of the DITA home directory | |
export DITA_HOME="$BUILD_FILES/../bin/dita-ot/" | |
# Set the absolute path of the DITA home directory again (weird, but necessary) | |
export DITA_DIR="$BUILD_FILES/../bin/dita-ot/" | |
# Execute the build script in the shell that is provided by the DITA start script | |
echo "$BUILD_FILES/build_html.sh" | "$DITA_HOME/startcmd.sh" | |
# Display OS X system notification via <https://github.com/alloy/terminal-notifier> | |
echo 'HTML build succeeded. Committing…' | /usr/local/bin/terminal-notifier -sound default | |
# Exit with status of last command | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment