<commit_before>#!/bin/bash

## Usage: ./generate-release.sh [-f] 3 0 0
# must be run from top-level scale folder

if [[ $1 == "-f" ]]; then
    force=1
    shift
fi
ver=($*)
verstring=$(IFS=. ; echo "${ver[*]}")
tput setaf 2
echo "Building release $verstring"
tput sgr0

if [[ $(git rev-parse --abbrev-ref HEAD) != "master" ]]; then
    tput setaf 1
    echo "Current branch is not master!"
    tput sgr0
    git rev-parse --abbrev-ref HEAD
    if [[ ! $force ]]; then exit 1; fi
fi

git diff-index --quiet HEAD
if [[ $? ]]; then
    tput setaf 1
    echo "Current index is not clean!"
    tput sgr0
    git diff-index HEAD
    if [[ ! $force ]]; then exit 1; fi
fi

tput setaf 2
echo -e "\nChange the revision on master"
tput sgr0
sed -i "" -e "s/^VERSION = version_info_t.*$/VERSION = version_info_t($1, $2, $3, '-snapshot')/" scale/scale/__init__.py
sed -i "" -e "s/^VERSION = version_info_t.*$/VERSION = version_info_t($1, $2, $3, '-snapshot___BUILDNUM___')/" scale/scale/__init__.py.template
grep "VERSION = " scale/scale/__init__.py scale/scale/__init__.py.template

tput setaf 2
echo -e "\nCommit the change"
tput sgr0
git commit -a -m "Update snapshot revision to $vestring"

tput setaf 2<commit_msg>Fix generate release script<commit_after>#!/bin/bash

## Usage: ./generate-release.sh [-f] 3 0 0
# must be run from top-level scale folder

if [[ $1 == "-f" ]]; then
    force=1
    shift
fi
ver=($*)
verstring=$(IFS=. ; echo "${ver[*]}")
tput setaf 2
echo "Building release $verstring"
tput sgr0

if [[ $(git rev-parse --abbrev-ref HEAD) != "master" ]]; then
    tput setaf 1
    echo "Current branch is not master!"
    tput sgr0
    git rev-parse --abbrev-ref HEAD
    if [[ ! $force ]]; then exit 1; fi
fi

git diff-index --quiet HEAD
if [[ $? != 0 ]]; then
    tput setaf 1
    echo "Current index is not clean!"
    tput sgr0
    git diff-index HEAD
    if [[ ! $force ]]; then exit 1; fi
fi

tput setaf 2
echo -e "\nChange the revision on master"
tput sgr0
sed -i "" -e "s/^VERSION = version_info_t.*$/VERSION = version_info_t($1, $2, $3, '-snapshot')/" scale/scale/__init__.py
sed -i "" -e "s/^VERSION = version_info_t.*$/VERSION = version_info_t($1, $2, $3, '-snapshot___BUILDNUM___')/" scale/scale/__init__.py.template
grep "VERSION = " scale/scale/__init__.py scale/scale/__init__.py.template

tput setaf 2
echo -e "\nCommit the change"
tput sgr0
git commit -a -m "Update snapshot revision to $vestring"

tput setaf 2
{'fraction_non_alphanumeric': 0.15605749486652978, 'fraction_numerical': 0.020123203285420943, 'mean_word_length': 3.2439024390243905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3055633', 'n_tokens_mistral': 941, 'n_tokens_neox': 897, 'n_words': 299}