<commit_before>#!/bin/sh
REPO_PATH=github.com/bvanderlaan/Taranis.git
DOCS_PATH=gh-pages/docs
HTML_PATH=build/doc/html
COMMIT_USER="Documentation Builder"
COMMIT_EMAIL="<EMAIL>"

# Only update docs on master branch.
if [ ${TRAVIS_BRANCH} != "master" ]; then exit 0; fi

# Only update docs for the first or only build job. This way we are not updating the docs 
# multiple times on a matrix configuration.
BUILD_JOB_SEP_POS=$(expr index ${TRAVIS_JOB_NUMBER} .)

echo ${TRAVIS_JOB_NUMBER}
echo ${BUILD_JOB_SEP_POS}
echo ${TRAVIS_JOB_NUMBER#*.}

if [ ${BUILD_JOB_SEP_POS} > 0 ] && [ ${TRAVIS_JOB_NUMBER#*.} > 1 ]; then exit 0; fi

# Exit with nonzero exit code if anything fails
set -e

echo 'Uploading documentation to the gh-pages branch...'

# Checkout and clean out the docs folder
git clone -b gh-pages https://${REPO_PATH} --single-branch gh-pages
cd "${DOCS_PATH}"
git rm -rf .
cd -

if [ -d "${HTML_PATH}" ]; then
    # copy the newly created documents into the gh-pages docs folder.
    cp -R "${HTML_PATH}" "${DOCS_PATH}"

    # commit the new documentation
    cd ${DOCS_PATH}
    git add --all
    git config user.name "${COMMIT_USER}"
    git config user.email "${COMMIT_EMAIL}"
    git commit -m"Automated documentation build for changeset ${TRAVIS_COMMIT}"
    git push --force "https://${GH_REPO_TOKEN}@${REPO_PATH}" > /dev/null 2>&1
    cd -
else
    echo '' >&2
    echo 'Warning: No documentation (html) files have been found!' >&2
    echo 'Warning: Not going to push the documentation to GitHub!' >&2
    exit 1<commit_msg>Remove debug messages and skip publication on osx. The version of osx used on travis-ci by default has an older version of bash which uses a different 'expr' syntax then the version of bash on the linux machines. Since the publication is setup to only happen once on the first build job and that happens to be a linux box this change set gets around the differeances in bash version simply by skipping publication on osx machines.<commit_after>#!/bin/sh
REPO_PATH=github.com/bvanderlaan/Taranis.git
DOCS_PATH=gh-pages/docs
HTML_PATH=build/doc/html
COMMIT_USER="Documentation Builder"
COMMIT_EMAIL="<EMAIL>"

# Only update docs on master branch.
if [ ${TRAVIS_BRANCH} != "master" ]; then exit 0; fi

# The version of OSX (10.9) used by default on Travis-ci has an older version of bash (3.2.1)
# which uses a different expr syntax. to deal with this issue quickly and since the first build
# is a linux machine simply skip publication of the doxygen documentation on osx machines.
if [ ${TRAVIS_OS_NAME} == "linux" ]; then exit 0; fi

# Only update docs for the first or only build job. This way we are not updating the docs 
# multiple times on a matrix configuration.
BUILD_JOB_SEP_POS=$(expr index ${TRAVIS_JOB_NUMBER} .)
if [ ${BUILD_JOB_SEP_POS} > 0 ] && [ ${TRAVIS_JOB_NUMBER#*.} > 1 ]; then exit 0; fi

# Exit with nonzero exit code if anything fails
set -e

echo 'Uploading documentation to the gh-pages branch...'

# Checkout and clean out the docs folder
git clone -b gh-pages https://${REPO_PATH} --single-branch gh-pages
cd "${DOCS_PATH}"
git rm -rf .
cd -

if [ -d "${HTML_PATH}" ]; then
    # copy the newly created documents into the gh-pages docs folder.
    cp -R "${HTML_PATH}" "${DOCS_PATH}"

    # commit the new documentation
    cd ${DOCS_PATH}
    git add --all
    git config user.name "${COMMIT_USER}"
    git config user.email "${COMMIT_EMAIL}"
    git commit -m"Automated documentation build for changeset ${TRAVIS_COMMIT}"
    git push --force "https://${GH_REPO_TOKEN}@${REPO_PATH}" > /dev/null 2>&1
    cd -
else
    echo '' >&2
    echo 'Warning: No documentation (html) files have been found!' >&2
    echo 'Warning: Not going to push the documentation to GitHub!' >&2
    exit 1
{'fraction_non_alphanumeric': 0.10930418555051986, 'fraction_numerical': 0.007198080511863503, 'mean_word_length': 3.898172323759791, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2529370', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1195, 'n_words': 474}