Skip to content

Instantly share code, notes, and snippets.

@supki
Created June 26, 2013 14:06
Show Gist options
  • Save supki/5867639 to your computer and use it in GitHub Desktop.
Save supki/5867639 to your computer and use it in GitHub Desktop.
M
#!/bin/bash -e
# $branch supposedly points to previous git branch
function git-checkout-back ()
{
git checkout "${branch}"
}
echo -e "\n * Generating docs..\n"
cabal configure --enable-tests
cabal haddock --hyperlink-source
echo -e "\n * Checking out docs branch..\n"
# return back on exit
trap git-checkout-back EXIT
branch=`git rev-parse --abbrev-ref HEAD` # spell to get current branch name
if [ "${branch}" != "gh-pages" ]; then
git checkout gh-pages
fi
git pull --rebase origin gh-pages
echo -e "\n * Updating docs..\n"
for directory in dist/doc/html/*; do
cp --recursive "${directory}"/* .
done
echo -e "\n * Preparing commit..\n"
git add .
git status
if ! `git diff-index --quiet HEAD --`; then
echo -e "\n * Committing..\n"
git commit --message "Update docs."
git push origin gh-pages
else
echo -e "\n * Nothing to commit.\n"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment