#!/bin/bash
RESULT_TMP_DIR=results_dump
git_top_level=$(git rev-parse --show-toplevel)
results_dir_l=(${git_top_level}/results ${git_top_level}/../results ${git_top_level}/analysis/results "0")
for results_dir in ${results_dir_l[@]}; do
if [[ -e $results_dir ]]; then
break
fi
done
if [ "$results_dir" == "0" ]; then
echo "Could not find results dir. Will not move files."
exit -1
fi
echo $results_dir
branch=`git rev-parse --abbrev-ref HEAD`
commit=`git rev-parse HEAD`
commit=${commit:0:8}
date=`date +%Y-%m-%d`
mkdir -p ${results_dir}/${branch}
commit_dir=${results_dir}/${branch}/${date}_${commit}/
if [[ ! -e $commit_dir ]]; then
mkdir $commit_dir
else
echo "$commit_dir already exists in $branch. Will not move files."
exit -1
fi
echo "Moving files ..."
set -x
mv $RESULT_TMP_DIR/* $commit_dir
set +x