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

function deployer_init() {
	perform 'Create $deployerFile file for current project'
	if [[ -f ./$deployerFile ]]; then
		warning "$deployerFile already exists, run 'deployer config:edit' to edit this file'"
	else
		cp "$DEPLOYER_LOCATION/template/main.sh.dist" ./$deployerFile
		performed
	fi

	perform 'Initialize git repo (safe)'
	git init &>/dev/null
	performed
	perform "Set push configuration to 'current'"
	git config --global push.default current
	performed
	perform "Set pull configuration to 'current'"
	git config --global pull.default current
	performed
	info "Please configure the $deployerFile file in order to use deployer"
}

function deployer_use() {
	if [[ $localProjectLocation == $(pwd) ]]; then
		warning 'Project already selected'
		return
	fi
	
	attempt "set current directory as project dir"

	perform "locate '$deployerFile' file"
	if [[ ! -f ./$deployerFile ]]; then
		error "Unable to locate '$deployerFile' file in current directory, run 'deployer init' to create one."
		return 1
	fi
	performed
	perform "check if $projectFile file exists for deployer"
	if [[ -f $DEPLOYER_LOCATION/../config/$projectFile ]]; then
		performed
	else
		performed 'not found, creating...'
		perform "create $projectFile for deployer"
		sudo touch $DEPLOYER_LOCATION/../config/$projectFile
		if [[ $? == 0 ]]; then
			performed
		else
			error "unable to create $projectFile file, please resort to manual creation of file"
			return
		fi
	fi

	perform 'Make sure the logs folder/file exists'
	if [[ ! -f $projectsLog ]]; then
		mkdir $DEPLOYER_LOCATION/../logs
		touch $projectsLog
	fi
	performed

	perform 'set current project dir as deployer current project'
	currentDir=$(pwd)
	echo "#!/usr/bin/env bash
readonly localProjectLocation='$currentDir'" > "$DEPLOYER_LOCATION/../config/$projectFile"
	performed

	perform 'store current project dir in projects.log file'
	isInFile=$(cat $projectsLog | grep $currentDir)
	if [[ -z $isInFile ]]; then
		name=$(deployer_FolderNameFromPath $currentDir)
		echo "[$name] - $currentDir" >> $projectsLog
		performed
	else
		performed 'Already exists'
	fi
}

function Deployer_commit_log() {
	attempt 'show all commit logs'
	if [[ -z $1 ]]; then
		filter=$(date '+%d-%m-%Y')
	else
		if [[ "$1" == 'yesterday' ]]; then
			filter=$(yesterday)
		else
			filter="$1"
		fi
	fi

	cat -n "$DEPLOYER_LOCATION"/../logs/project-commits.log | grep "$filter"
}<commit_msg>Filter output when showing logs<commit_after>#!/usr/bin/env bash

function deployer_init() {
	perform 'Create $deployerFile file for current project'
	if [[ -f ./$deployerFile ]]; then
		warning "$deployerFile already exists, run 'deployer config:edit' to edit this file'"
	else
		cp "$DEPLOYER_LOCATION/template/main.sh.dist" ./$deployerFile
		performed
	fi

	perform 'Initialize git repo (safe)'
	git init &>/dev/null
	performed
	perform "Set push configuration to 'current'"
	git config --global push.default current
	performed
	perform "Set pull configuration to 'current'"
	git config --global pull.default current
	performed
	info "Please configure the $deployerFile file in order to use deployer"
}

function deployer_use() {
	if [[ $localProjectLocation == $(pwd) ]]; then
		warning 'Project already selected'
		return
	fi
	
	attempt "set current directory as project dir"

	perform "locate '$deployerFile' file"
	if [[ ! -f ./$deployerFile ]]; then
		error "Unable to locate '$deployerFile' file in current directory, run 'deployer init' to create one."
		return 1
	fi
	performed
	perform "check if $projectFile file exists for deployer"
	if [[ -f $DEPLOYER_LOCATION/../config/$projectFile ]]; then
		performed
	else
		performed 'not found, creating...'
		perform "create $projectFile for deployer"
		sudo touch $DEPLOYER_LOCATION/../config/$projectFile
		if [[ $? == 0 ]]; then
			performed
		else
			error "unable to create $projectFile file, please resort to manual creation of file"
			return
		fi
	fi

	perform 'Make sure the logs folder/file exists'
	if [[ ! -f $projectsLog ]]; then
		mkdir $DEPLOYER_LOCATION/../logs
		touch $projectsLog
	fi
	performed

	perform 'set current project dir as deployer current project'
	currentDir=$(pwd)
	echo "#!/usr/bin/env bash
readonly localProjectLocation='$currentDir'" > "$DEPLOYER_LOCATION/../config/$projectFile"
	performed

	perform 'store current project dir in projects.log file'
	isInFile=$(cat $projectsLog | grep $currentDir)
	if [[ -z $isInFile ]]; then
		name=$(deployer_FolderNameFromPath $currentDir)
		echo "[$name] - $currentDir" >> $projectsLog
		performed
	else
		performed 'Already exists'
	fi
}

function Deployer_commit_log() {
	attempt 'show all commit logs'
	if [[ -z $1 ]]; then
		filter=$(date '+%d-%m-%Y')
	else
		if [[ "$1" == 'yesterday' ]]; then
			filter=$(yesterday)
		else
			filter="$1"
		fi
	fi

	info "Applying filter: $filter"

	cat -n "$DEPLOYER_LOCATION"/../logs/project-commits.log | grep "$filter"
}
{'fraction_non_alphanumeric': 0.1195784353465748, 'fraction_numerical': 0.002026753141467369, 'mean_word_length': 4.1246105919003115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6915053', 'n_tokens_mistral': 1729, 'n_tokens_neox': 1578, 'n_words': 526}