<commit_before>#!/bin/bash
#
# Eve.js Compilation Script <evejs.com>
#
# @author: <NAME> <@Yuffster>
#
# Usage:
#
#     ./build.sh <version>
#
# Assuming you don't have any bugs in your code, this file will perform the
# following actions:
#
#     1. Run the unit test suite against src/eve.js
#     2. Compress eve.js with copyright notice using Google Closure Compiler
#     3. Re-run the unit test suite against the minified JavaScript file
#     4. Change package.json to reflect new version number
#     5. Change the second line of Eve.js to reflect new version number
#     6. Commit changes to Git
#     7. Create a new tag with the version number provided
#     8. Merge master branch with stable branch
#     9. Push tags and changes through Git
#
# If the unit tests fail, the script will attempt to restore the previous
# version of eve.min.js.

# Ensure that we've received a single argument.
if [ $# -lt 1 ]; then
	echo "Usage: $0 <version number>"
	exit 1
fi

VERSION=$1
VERSION_STRING="Eve.js <evejs.com> - v$VERSION $(date +"%B %d, %Y")"

# Ensure the version number is in the currect format, mainly so we don't end
# up accidentally tagging something as vv1.3.
if [[ $VERSION =~ [^0-9.]|\.\.|\.$ ]]; then
	echo "Version number can only contain numbers separated by dots."
	exit 1
fi

# Second argument is the location of CDNJS.
if [ $# -eq 2 ]; then
	CDN="$2ajax/libs/eve.js/"
	if [ ! -d "$CDN" ]; then
		echo "Directory doesn't exist: $CDN"
		exit 1
	fi
fi

# keeps track of whether or not we've changed eve.min.js
TOUCHED=0 

# Checks to see if the last command executed correctly.  If not, we roll back
# any relevant changes and exit with a failure code.
function check_status {
	if [ "$?" -gt 0 ]; then
		echo "Build failed. Next time, try compiling with fewer bugs."
		if [ $TOUCHED -eq 1 ]; then
			echo "Restoring previous version of eve.min.js"
			git checkout eve.min.js
		fi
		exit 1
	fi
}

echo "Stashing changes for clean working tree."
echo "Run 'git stash pop' to restore if something goes wrong."
git stash --keep-index -q

# Run our tests against the main eve.js file and ensure that they've passed.
echo "Running tests against src/eve.js..."<commit_msg>Ensure we're on the master branch and not stable.<commit_after>#!/bin/bash
#
# Eve.js Compilation Script <evejs.com>
#
# @author: <NAME> <@Yuffster>
#
# Usage:
#
#     ./build.sh <version>
#
# Assuming you don't have any bugs in your code, this file will perform the
# following actions:
#
#     1. Run the unit test suite against src/eve.js
#     2. Compress eve.js with copyright notice using Google Closure Compiler
#     3. Re-run the unit test suite against the minified JavaScript file
#     4. Change package.json to reflect new version number
#     5. Change the second line of Eve.js to reflect new version number
#     6. Commit changes to Git
#     7. Create a new tag with the version number provided
#     8. Merge master branch with stable branch
#     9. Push tags and changes through Git
#
# If the unit tests fail, the script will attempt to restore the previous
# version of eve.min.js.

# Ensure that we've received a single argument.
if [ $# -lt 1 ]; then
	echo "Usage: $0 <version number>"
	exit 1
fi

VERSION=$1
VERSION_STRING="Eve.js <evejs.com> - v$VERSION $(date +"%B %d, %Y")"

# Ensure the version number is in the currect format, mainly so we don't end
# up accidentally tagging something as vv1.3.
if [[ $VERSION =~ [^0-9.]|\.\.|\.$ ]]; then
	echo "Version number can only contain numbers separated by dots."
	exit 1
fi

# Second argument is the location of CDNJS.
if [ $# -eq 2 ]; then
	CDN="$2ajax/libs/eve.js/"
	if [ ! -d "$CDN" ]; then
		echo "Directory doesn't exist: $CDN"
		exit 1
	fi
fi

# keeps track of whether or not we've changed eve.min.js
TOUCHED=0 

# Checks to see if the last command executed correctly.  If not, we roll back
# any relevant changes and exit with a failure code.
function check_status {
	if [ "$?" -gt 0 ]; then
		echo "Build failed. Next time, try compiling with fewer bugs."
		if [ $TOUCHED -eq 1 ]; then
			echo "Restoring previous version of eve.min.js"
			git checkout eve.min.js
		fi
		exit 1
	fi
}

echo "Ensuring we're on the master branch"
git checkout master

echo "Stashing changes for clean working tree."
echo "Run 'git stash pop' to restore if something goes wrong."
git stash --keep-index -q

# Run our tests against the main eve.js file and ensure that they've passed.
echo "Running tests against src/eve.js..."
{'fraction_non_alphanumeric': 0.10160786065207682, 'fraction_numerical': 0.011165698972755694, 'mean_word_length': 3.237464522232734, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '269168', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1397, 'n_words': 651}