|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +echo "enter the directory(format is ../workspace/the_current_project, but you only input the_current_project or workspace/the_current_project): " |
| 4 | +read dir # input directory |
| 5 | +dir_name=$(dirname $dir) |
| 6 | +project_name=$(basename $dir) |
| 7 | + |
| 8 | +function juageInteractionMode(){ |
| 9 | + if [[ $1 == "\\" || $1 == "." ]];then |
| 10 | + return 1; # the relative path mode |
| 11 | + fi |
| 12 | + return 0; # the absolute path mode |
| 13 | +} |
| 14 | + |
| 15 | +echo -n "enter the start date(format is xxxx-xx-xx): " |
| 16 | +read start_date # input start date |
| 17 | + |
| 18 | +if [[ ! -d "./out" ]];then |
| 19 | + mkdir ./out |
| 20 | +fi |
| 21 | + |
| 22 | +root_name="$(dirname $(dirname $(pwd)))" # the parent directory of the current workspace |
| 23 | +juageInteractionMode $dir_name |
| 24 | +mode=$? # 1: relative mode otherwise absolute mode |
| 25 | +project="" # the current project directory |
| 26 | +if [[ $mode == 1 ]];then |
| 27 | + project="${root_name}/$(basename $(dirname $(pwd)))/${project_name}" |
| 28 | +else |
| 29 | + project="${root_name}/${dir}" |
| 30 | +fi |
| 31 | +out_name="" # the current project statistics output directory. |
| 32 | + |
| 33 | +if [[ ! -z $dir ]]; then |
| 34 | + if [[ ! -z $start_date ]]; then |
| 35 | + out_name="`pwd`/out/statistics_${project_name}_${start_date}_$(date "+%Y-%m-%d_%H%M%S")" |
| 36 | + mkdir -p $out_name |
| 37 | + echo -e "\n the current project directory:\n $project" |
| 38 | + echo -e "\n the current out directory:\n $out_name" |
| 39 | + echo -e "\n" |
| 40 | + python2 gitstats -c start_date=${start_date} ${project} ${out_name} |
| 41 | + else |
| 42 | + out_name="`pwd`/out/statistics_${project_name}_$(date "+%Y-%m-%d_%H%M%S")" |
| 43 | + mkdir -p $out_name |
| 44 | + echo -e "\n the current project directory:\n $project" |
| 45 | + echo -e "\n the current out directory:\n $out_name" |
| 46 | + echo -e "\n" |
| 47 | + python2 gitstats -c ${project} ${out_name} |
| 48 | + fi |
| 49 | +else |
| 50 | + echo "the current project directory: $project" |
| 51 | + echo "the current out directory: $out_name" |
| 52 | + echo "the directory is not vaild." |
| 53 | +fi |
| 54 | +exit 0 |
| 55 | + |
0 commit comments