<commit_before>#!/bin/bash
# <NAME>
# ghist2gdrive.sh
# November 12, 2015
#
# This script backs up a git repository with history and all to google
# drive. This script is not recomended to be used everytime, because it
# produces much larger archives than `git2gdrive.sh`. This script is more
# like a weekly thing than a daily thing.
# 
# NOTE: This script requires https://github.com/prasmussen/gdrive to be
# in your path.
#
# USAGE:
# ./git2gdrive <LOCAL_DIR_TO_BKUP> [ANYTHING]
# 
# If any thing is placed in the [ANYTHING] position then the remote sync
# feature will be enabled and it will fetch updates from a remote. You can
# enable this if you would like. It does not really matter. That state is
# not saved from run to run of this script.
#
# It is important to note that it will upload it to the `backup` folder in
# gdrive creating it if the folder does not exist


LOCALDIR=$1
ENABLE_REMOTE_SYNC=$2

# Remote directory to place backups
REMOTEDIR="backup"



# Check that required programs are installed
# Please see the note in the preamble(at the top) for the required
# programs.
if ! hash drive 2>&1 /dev/null
then
    echo \`drive\` is not in your path, add it to your path to use this \
        script.
    exit
fi

# You also need `git` to run this script
if ! hash git 2>&1 /dev/null
then
    echo \`git\` is not installed. This is a required package for this \
        script.
    exit
fi

# Input Verification
# This stuff checks the arguements to the backup script.
if [ -z "$LOCALDIR" ]
then
    echo "You need to specify the directory to backup"
    exit
else
    if [ ! -d "$LOCALDIR" ]
    then
        echo "$LOCALDIR is not a directory"
        exit
    fi
fi

# Begin the meat of the script
DATE=$(date +%Y-%m-%d)
TARNAME="/tmp/$(basename $LOCALDIR)-${DATE}.bundle"

cd $LOCALDIR
echo Enter $(pwd)

# Fetch the latest updates from the remote if there is one
BRANCH_NAME=master
if [ ! -z $ENABLE_REMOTE_SYNC ]
then
    # on success return code is 0<commit_msg>Make the ghist script more reliable<commit_after>#!/bin/bash
# <NAME>
# ghist2gdrive.sh
# November 12, 2015
#
# This script backs up a git repository with history and all to google
# drive. This script is not recomended to be used everytime, because it
# produces much larger archives than `git2gdrive.sh`. This script is more
# like a weekly thing than a daily thing.
# 
# NOTE: This script requires https://github.com/prasmussen/gdrive to be
# in your path.
#
# USAGE:
# ./git2gdrive <LOCAL_DIR_TO_BKUP> [ANYTHING]
# 
# If any thing is placed in the [ANYTHING] position then the remote sync
# feature will be enabled and it will fetch updates from a remote. You can
# enable this if you would like. It does not really matter. That state is
# not saved from run to run of this script.
#
# It is important to note that it will upload it to the `backup` folder in
# gdrive creating it if the folder does not exist

function getGitRoot() {
    git rev-parse --show-toplevel
}

LOCALDIR=$1
ENABLE_REMOTE_SYNC=$2

# Remote directory to place backups
REMOTEDIR="backup"



# Check that required programs are installed
# Please see the note in the preamble(at the top) for the required
# programs.
if ! hash drive 2>&1 /dev/null
then
    echo \`drive\` is not in your path, add it to your path to use this \
        script.
    exit
fi

# You also need `git` to run this script
if ! hash git 2>&1 /dev/null
then
    echo \`git\` is not installed. This is a required package for this \
        script.
    exit
fi

# Input Verification
# This stuff checks the arguements to the backup script.
if [ -z "$LOCALDIR" ]
then
    echo "You need to specify the directory to backup"
    exit
else
    if [ ! -d "$LOCALDIR" ]
    then
        echo "$LOCALDIR is not a directory"
        exit
    fi
fi

# Enter the git directory to run the git commands
cd $LOCALDIR
echo Enter $(pwd)

# Name the the tar ball to upload
DATE=$(date +%Y-%m-%d)
TARNAME="/tmp/$(basename $(getGitRoot))-${DATE}.bundle"

# Fetch the latest updates from the remote if there is one
BRANCH_NAME=master
if [ ! -z $ENABLE_REMOTE_SYNC ]
then
    # on success return code is 0
{'fraction_non_alphanumeric': 0.08125151588649042, 'fraction_numerical': 0.007761338830948338, 'mean_word_length': 3.2958333333333334, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 2, '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': '3356474', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1262, 'n_words': 605}