<commit_before>#!/bin/bash
# This script will create a plugin jar file for a given plugin.

if [ "${1}" = "" -o "${2}" = "" ]; then
	echo "Usage Example: ${0} com.dmdirc.addons.windowstatus WindowStatusPlugin"
	echo "The above would create WindowStatusPlugin.jar in the plugins/ folder of the current dir"
	exit;
fi

srcdir=${PWD}
pluginname=${1}
foldername=${pluginname//.//}

newer=`find src/${foldername} -type f -newer ${srcdir}/plugins/${2}.jar 2>&1 | wc -l`

if [ $newer -eq 0 ]; then
	echo "${2}.jar appears to be up-to-date";
	exit 0;
fi

echo "Creating ${2}.jar for ${pluginname} (${foldername})"

if [ ! -e src/${foldername}/plugin.config ]; then
	echo "no plugin.config found";
	exit 0;
fi

#echo "looking for classes"
TMPDIR=`mktemp -d`
#echo "Using temp dir: ${TMPDIR}"
cd $TMPDIR

mkdir META-INF
if [ -e ${srcdir}/src/${foldername}/plugin.config ]; then
	cp ${srcdir}/src/${foldername}/plugin.config META-INF/
fi;

# Do the same for plugin.config
# This is rudimentary, it a version: section already exists (eg to specify
# friendlyversion) then it won't add the number= key.
if [ -e META-INF/plugin.config ]; then
	VERSIONLINE=`grep -n "version:$" META-INF/plugin.config | cut -f 1 -d ':'`

	if [ -z "$VERSIONLINE" ]; then
		sed 's/keysections:/keysections:\n  version/g' META-INF/plugin.config > META-INF/plugin.config.temp
		rm -Rf META-INF/plugin.config
		mv META-INF/plugin.config.temp META-INF/plugin.config		
	fi;

	if [ -d "$srcdir/.git" ]; then
		GIT="`which git` --git-dir $srcdir/.git";
		REV=$($GIT describe --tags `$GIT rev-list --max-count=1 HEAD -- src/$foldername`);
	else
		SVN=`which svn`	
		SVNREV=`$SVN info $srcdir/src/$foldername 2>&1 | grep "Last Changed Rev"`
		SVNREV=${SVNREV##*: }

		if [ -n "$SVNREV" ]; then
	                REV=`$SVN log -r $SVNREV | grep ^Git-version: | cut -f 2 -d ' '`
		else
			REV=0;
		fi;
	fi;

        echo "" >> META-INF/plugin.config<commit_msg>Fix createPluginJar not getting versions when using SVN<commit_after>#!/bin/bash
# This script will create a plugin jar file for a given plugin.

if [ "${1}" = "" -o "${2}" = "" ]; then
	echo "Usage Example: ${0} com.dmdirc.addons.windowstatus WindowStatusPlugin"
	echo "The above would create WindowStatusPlugin.jar in the plugins/ folder of the current dir"
	exit;
fi

srcdir=${PWD}
pluginname=${1}
foldername=${pluginname//.//}

newer=`find src/${foldername} -type f -newer ${srcdir}/plugins/${2}.jar 2>&1 | wc -l`

if [ $newer -eq 0 ]; then
	echo "${2}.jar appears to be up-to-date";
	exit 0;
fi

echo "Creating ${2}.jar for ${pluginname} (${foldername})"

if [ ! -e src/${foldername}/plugin.config ]; then
	echo "no plugin.config found";
	exit 0;
fi

#echo "looking for classes"
TMPDIR=`mktemp -d`
#echo "Using temp dir: ${TMPDIR}"
cd $TMPDIR

mkdir META-INF
if [ -e ${srcdir}/src/${foldername}/plugin.config ]; then
	cp ${srcdir}/src/${foldername}/plugin.config META-INF/
fi;

# Do the same for plugin.config
# This is rudimentary, it a version: section already exists (eg to specify
# friendlyversion) then it won't add the number= key.
if [ -e META-INF/plugin.config ]; then
	VERSIONLINE=`grep -n "version:$" META-INF/plugin.config | cut -f 1 -d ':'`

	if [ -z "$VERSIONLINE" ]; then
		sed 's/keysections:/keysections:\n  version/g' META-INF/plugin.config > META-INF/plugin.config.temp
		rm -Rf META-INF/plugin.config
		mv META-INF/plugin.config.temp META-INF/plugin.config		
	fi;

	if [ -d "$srcdir/.git" ]; then
		GIT="`which git` --git-dir $srcdir/.git";
		REV=$($GIT describe --tags `$GIT rev-list --max-count=1 HEAD -- src/$foldername`);
	else
		cd $srcdir;
		SVN=`which svn`	
		SVNREV=`$SVN info $srcdir/src/$foldername 2>&1 | grep "Last Changed Rev"`
		SVNREV=${SVNREV##*: }

		if [ -n "$SVNREV" ]; then
	                REV=`$SVN log -r $SVNREV | grep ^Git-version: | cut -f 2 -d ' '`
		else
			REV=0;
		fi;
		cd $TMPDIR;
	fi;

        echo "" >> META-INF/plugin.config
{'fraction_non_alphanumeric': 0.17435897435897435, 'fraction_numerical': 0.009230769230769232, 'mean_word_length': 3.4430523917995446, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3903166', 'n_tokens_mistral': 1582, 'n_tokens_neox': 1479, 'n_words': 424}