<commit_before>#!/usr/bin/env bash

# The MIT License (MIT)
# 
# Copyright (c) 2015 Secret Lab Pty. Ltd. and Yarn Spinner contributors.
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

LOGFILE="export.log"
OUTDIR="`pwd`/Builds"
SOURCE_FILES="YarnSpinner/*.cs"

NO_EXAMPLES=0

SOURCE_BUILD=0

set -e

function show_help {
	echo "package.sh: Package Yarn Spinner into a .unitypackage for distribution"
	echo
	echo "Usage: package.sh [-hsx]"
	echo "  -s: Package the source code, not a built DLL"
	echo "  -c: Show the changes since the last tag and exit"
	echo "  -h: Show this text and exit"
	echo "  -x: Do not include example project assets"
}

function show_changes {
	LATEST_TAG=`git describe --abbrev=0 --tags`
	COMMITS_SINCE_THEN=`git rev-list $LATEST_TAG.. --count`

	if [ $COMMITS_SINCE_THEN -eq "0" ]; then
		echo "There has been no further work since the last tag."
	else
		echo "There have been $COMMITS_SINCE_THEN commits since $LATEST_TAG:"

		git log $LATEST_TAG.. --pretty=format:"* %s"
	fi
}


while getopts ":xhsc" opt; do
	
	case $opt in
	   x) NO_EXAMPLES=1 ;;
	   h) show_help ; exit 0 ;;
	   s) SOURCE_BUILD=1 ;;
	   c) show_changes ; exit 0 ;;
	   \?) echo "Invalid option: -$OPTARG" >&2; echo; show_help ; exit 0 ;;
	esac

done

if [ `uname -s` != "Darwin" ]; then
	echo "This script only works on OS X."
	exit 1
fi

# Clean the Unity directory of anything ignored
echo "Cleaning Unity project..."
git clean -f -d -X Unity

# Build the Yarn Spinner DLL
echo "Building Yarn Spinner..."
./build.sh

if [ $SOURCE_BUILD == 1 ]; then
	echo "Removing YarnSpinner.dll..."
	# Remove the built DLL from the Unity project (we built it to ensure that it actually works)
	rm -v "Unity/Assets/Yarn Spinner/Code/YarnSpinner.dll"
	
	echo "Copying Yarn Spinner source in..."
	# Copy the source files in
	cp -v $SOURCE_FILES "Unity/Assets/Yarn Spinner/Code/"
	
fi

# Next, determine what build name this is.

# Strips "v" from tag names
function strip-v () { echo -n "${1#v}"; }

FULL_VERSION=$(strip-v $(git describe --tags --match 'v[0-9]*' --always --dirty))

if [ $SOURCE_BUILD == 1 ]; then
	FULL_VERSION="$FULL_VERSION-source"
fi

if [ $NO_EXAMPLES == 1 ]; then
	FULL_VERSION="$FULL_VERSION-minimal"
fi

echo "Packaging Version $FULL_VERSION with Unity..."
<commit_msg>package.sh now includes branch name if not master<commit_after>#!/usr/bin/env bash

# The MIT License (MIT)
# 
# Copyright (c) 2015 Secret Lab Pty. Ltd. and Yarn Spinner contributors.
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

LOGFILE="export.log"
OUTDIR="`pwd`/Builds"
SOURCE_FILES="YarnSpinner/*.cs"

NO_EXAMPLES=0

SOURCE_BUILD=0

set -e

function show_help {
	echo "package.sh: Package Yarn Spinner into a .unitypackage for distribution"
	echo
	echo "Usage: package.sh [-hsx]"
	echo "  -s: Package the source code, not a built DLL"
	echo "  -c: Show the changes since the last tag and exit"
	echo "  -h: Show this text and exit"
	echo "  -x: Do not include example project assets"
}

function show_changes {
	LATEST_TAG=`git describe --abbrev=0 --tags`
	COMMITS_SINCE_THEN=`git rev-list $LATEST_TAG.. --count`

	if [ $COMMITS_SINCE_THEN -eq "0" ]; then
		echo "There has been no further work since the last tag."
	else
		echo "There have been $COMMITS_SINCE_THEN commits since $LATEST_TAG:"

		git log $LATEST_TAG.. --pretty=format:"* %s"
	fi
}


while getopts ":xhsc" opt; do
	
	case $opt in
	   x) NO_EXAMPLES=1 ;;
	   h) show_help ; exit 0 ;;
	   s) SOURCE_BUILD=1 ;;
	   c) show_changes ; exit 0 ;;
	   \?) echo "Invalid option: -$OPTARG" >&2; echo; show_help ; exit 0 ;;
	esac

done

if [ `uname -s` != "Darwin" ]; then
	echo "This script only works on OS X."
	exit 1
fi

# Clean the Unity directory of anything ignored
echo "Cleaning Unity project..."
git clean -f -d -X Unity

# Build the Yarn Spinner DLL
echo "Building Yarn Spinner..."
./build.sh

if [ $SOURCE_BUILD == 1 ]; then
	echo "Removing YarnSpinner.dll..."
	# Remove the built DLL from the Unity project (we built it to ensure that it actually works)
	rm -v "Unity/Assets/Yarn Spinner/Code/YarnSpinner.dll"
	
	echo "Copying Yarn Spinner source in..."
	# Copy the source files in
	cp -v $SOURCE_FILES "Unity/Assets/Yarn Spinner/Code/"
	
fi

# Next, determine what build name this is.

# Strips "v" from tag names
function strip-v () { echo -n "${1#v}"; }

FULL_VERSION=$(strip-v $(git describe --tags --match 'v[0-9]*' --always --dirty))

CURRENT_BRANCH_NAME="`git rev-parse --abbrev-ref HEAD`"

if [ $CURRENT_BRANCH_NAME != "master" ]; then
	FULL_VERSION="$FULL_VERSION-$CURRENT_BRANCH_NAME"
fi

if [ $SOURCE_BUILD == 1 ]; then
	FULL_VERSION="$FULL_VERSION-source"
fi

if [ $NO_EXAMPLES == 1 ]; then
	FULL_VERSION="$FULL_VERSION-minimal"
fi



echo "Packaging Version $FULL_VERSION with Unity..."

{'fraction_non_alphanumeric': 0.10298023015638831, 'fraction_numerical': 0.006196518146946002, 'mean_word_length': 3.876978417266187, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '41957', 'n_tokens_mistral': 2297, 'n_tokens_neox': 2152, 'n_words': 901}