<commit_before>#! /bin/bash

function download() {
	plugin=$1

	if [[ ! -f ${plugin}.hpi ]]; then

		url=http://updates.jenkins-ci.org/latest/${plugin}.hpi
		echo "download plugin : $plugin from $url"

		curl -s -f -L $url -o ${plugin}.hpi
		if [[ $? -ne 0 ]]
		then
			>&2 echo "failed to download plugin ${plugin}"
			exit -1
		fi
	else
		echo "$plugin is allready downloaded."
	fi	
	resolveDependencies $1
}

function resolveDependencies() {	
	plugin=$1

	dependencies=`jrunscript -e '\
	java.lang.System.out.println(\
		new java.util.jar.JarFile("'${plugin}.hpi'")\
			.getManifest()\
			.getMainAttributes()\
			.getValue("Plugin-Dependencies")\
	);'`

	if [[ "$dependencies" == "null" ]]; then
		echo " > plugin has no dependencies"
		return
	fi

	echo " > depends on  ${dependencies}"

	IFS=',' read -a array <<< "${dependencies}"

    for d in "${array[@]}"
	do
		plugin=$(echo $d | cut -d':' -f1 -)
		if [[ $d == *"resolution:=optional"* ]] 
		then	
			echo "skipping optional dependency $plugin"
		else
    		download $plugin
		fi
	done
}


shift
for plugin in "$@"
do
    download $plugin
done
<commit_msg>typo: allready -> already (#278)<commit_after>#! /bin/bash

function download() {
	plugin=$1

	if [[ ! -f ${plugin}.hpi ]]; then

		url=http://updates.jenkins-ci.org/latest/${plugin}.hpi
		echo "download plugin : $plugin from $url"

		curl -s -f -L $url -o ${plugin}.hpi
		if [[ $? -ne 0 ]]
		then
			>&2 echo "failed to download plugin ${plugin}"
			exit -1
		fi
	else
		echo "$plugin is already downloaded."
	fi	
	resolveDependencies $1
}

function resolveDependencies() {	
	plugin=$1

	dependencies=`jrunscript -e '\
	java.lang.System.out.println(\
		new java.util.jar.JarFile("'${plugin}.hpi'")\
			.getManifest()\
			.getMainAttributes()\
			.getValue("Plugin-Dependencies")\
	);'`

	if [[ "$dependencies" == "null" ]]; then
		echo " > plugin has no dependencies"
		return
	fi

	echo " > depends on  ${dependencies}"

	IFS=',' read -a array <<< "${dependencies}"

    for d in "${array[@]}"
	do
		plugin=$(echo $d | cut -d':' -f1 -)
		if [[ $d == *"resolution:=optional"* ]] 
		then	
			echo "skipping optional dependency $plugin"
		else
    		download $plugin
		fi
	done
}


shift
for plugin in "$@"
do
    download $plugin
done

{'fraction_non_alphanumeric': 0.17761989342806395, 'fraction_numerical': 0.007548845470692718, 'mean_word_length': 3.0815217391304346, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1310720', 'n_tokens_mistral': 904, 'n_tokens_neox': 795, 'n_words': 221}