<commit_before>#!/bin/bash

# Script to update the ITSLanguage GitHub pages website.
# Inspiration from https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
#
# The script should potentially do two things. It should either update
# the esdocs for master, or add a version to it.
#
# NOTE:
# Travis has a convenient "pages" provider. This provider works awesome
# and saves the script that is below. BUT it has one huge drawback: you
# can only use it with an personal access token. This way, worst case,
# someone could gane access to the key provider its repositories. So we
# should limit that risk by using this script.

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

SOURCE_BRANCH="master"
TARGET_BRANCH="gh-pages"

# Pull requests and commits to other branches shouldn't try to deploy
# new GitHub pages. Only allow master and vX.X.X branches (= a tag for
# a new version).
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_TAG" == "" ]; then
    exit 0
fi

#

# identify repo url with GITHUB_TOKEN
REPO_URL=`git remote -v | grep -m1 "^origin" | sed -Ene's#.*(<EMAIL>:[^[:space:]]*).*#\1#p'`
if [ -z "$REPO_URL" ]; then
  echo "-- ERROR:  Could not identify Repo url."
  echo "   It is possible this repo is already using HTTPS instead of SSH."
  exit 1
fi

USER=`echo $REPO_URL | sed -Ene's#<EMAIL>:([^/]*)/(.*).git#\1#p'`
if [ -z "$USER" ]; then
  echo "-- ERROR:  Could not identify User."
  exit 1
fi

REPO=`echo $REPO_URL | sed -Ene's#<EMAIL>:([^/]*)/(.*).git#\2#p'`
if [ -z "$REPO" ]; then
  echo "-- ERROR:  Could not identify Repo."
  exit 1
fi

REPO_HTTPS_URL="https://$GITHUB_TOKEN@github.com/$USER/$REPO.git"

# Clone the existing gh-pages for this repo into out/
# Create a new empty branch if gh-pages doesn't exist yet (should only
# happen on first deploy)
git clone $REPO out
cd out
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH

echo "Deploy $TARGET_BRANCH docs!"

# create directory. If it exists... wel then it will
# be wiped!
rm -Rf ./$TARGET_BRANCH
mkdir $TARGET_BRANCH
# copy documentation to place
cp -r ../docs/* ./$TARGET_BRANCH

# Now let's go have some fun with the cloned repo
git config user.name "$COMMIT_AUTHOR_NAME"
git config user.email "$COMMIT_AUTHOR_EMAIL"

# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add -A .<commit_msg>fix some missing pieces in gh-pages script<commit_after>#!/bin/bash

# Script to update the ITSLanguage GitHub pages website.
# Inspiration from https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
#
# The script should potentially do two things. It should either update
# the esdocs for master, or add a version to it.
#
# NOTE:
# Travis has a convenient "pages" provider. This provider works awesome
# and saves the script that is below. BUT it has one huge drawback: you
# can only use it with an personal access token. This way, worst case,
# someone could gane access to the key provider its repositories. So we
# should limit that risk by using this script.

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

SOURCE_BRANCH="master"
TARGET_BRANCH="gh-pages"

# Pull requests and commits to other branches shouldn't try to deploy
# new GitHub pages. Only allow master and vX.X.X branches (= a tag for
# a new version).
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_TAG" == "" ]; then
    exit 0
fi

#Save some useful information
REPO_SSH_URL=`git config remote.origin.url`
SHA=`git rev-parse --verify HEAD`

# identify repo url with GITHUB_TOKEN
REPO_URL=`git remote -v | grep -m1 "^origin" | sed -Ene's#.*(<EMAIL>:[^[:space:]]*).*#\1#p'`
if [ -z "$REPO_URL" ]; then
  echo "-- ERROR:  Could not identify Repo url."
  echo "   It is possible this repo is already using HTTPS instead of SSH."
  exit 1
fi

USER=`echo $REPO_URL | sed -Ene's#<EMAIL>:([^/]*)/(.*).git#\1#p'`
if [ -z "$USER" ]; then
  echo "-- ERROR:  Could not identify User."
  exit 1
fi

REPO=`echo $REPO_URL | sed -Ene's#<EMAIL>:([^/]*)/(.*).git#\2#p'`
if [ -z "$REPO" ]; then
  echo "-- ERROR:  Could not identify Repo."
  exit 1
fi

REPO_HTTPS_URL="https://$GITHUB_TOKEN@github.com/$USER/$REPO.git"

# Clone the existing gh-pages for this repo into out/
# Create a new empty branch if gh-pages doesn't exist yet (should only
# happen on first deploy)
rm -Rf ./out || exit 0
git clone $REPO_SSH_URL out
cd out
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH

echo "Deploy docs for branch \"$TRAVIS_BRANCH\""

# create directory. If it exists... wel then it will
# be wiped!
rm -Rf "./$TRAVIS_BRANCH"
mkdir "$TRAVIS_BRANCH"
# copy documentation to place
cp -r ../build/docs/* "./$TRAVIS_BRANCH"

# Now let's go have some fun with the cloned repo
git config user.name "$COMMIT_AUTHOR_NAME"
git config user.email "$COMMIT_AUTHOR_EMAIL"

# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add -A .
{'fraction_non_alphanumeric': 0.12357491856677524, 'fraction_numerical': 0.00753257328990228, 'mean_word_length': 3.840394088669951, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1051440', 'n_tokens_mistral': 1732, 'n_tokens_neox': 1638, 'n_words': 658}