Nothing recently, I wrote a code statistics gadget based on SVN in bash. You can specify a catalog of statistics, and the default recursive statistics subdirectory.
Currently, there is no capability to mask the specified directory. The code is rather rough. But get the sun out first.
# USAGE:./lines.sh [dir] # author:william # DESCRIPTION: Code submission based on SVN statistics tool # OPTIONS:---# CREATED : Ounset # Treat unset variables as an error # pay attention to the file type after the charge files_type= "*.cpp *.h *.lua" # need to count the people here Write to the person who needs the statistics, separated by a space. Ah, not yet. Smart declare-r coder_list= "Coder1 coder2" declare-i coder1 declare-i coder2 declare-r usage= "USAGE: $ [dir].
Default dir is current dir.\n "# ERROR codes; Declare-r e_bad_path=1 declare-r e_invailed_argu=2 declare-r e_not_svn_dir=3 #TODO shielding some DIR hasn't written yet, huh? TODO other WA Y get path not with/end GetPath () {#debug #echo dir_name: ${dir_name} #echo base_name: ${base_name} if [ $dir _name = = "/"] | | [$base _name = = "/"];
Then work_path= "/" Else Work_path=${dir_name}/${base_name} fi} statistic_codelines () {If [-Z "$"]; then echo "ERROR statis Tic_codelines not argument ' return fi pwd_length=${#PWD} echo '--------------------------' echo ' ${ PWD} "for coder in $CODER _list; Do local num=$ (echo "|" | grep ${coder} | wc-l) ((${coder} = = num)) If [$num-ne 0]; Then printf "%10s | %-7d\n "${coder} $num fi do echo"--------------------------"} # init check argument set Work_path in It_work_path () {if [$#-eq 1]; then if [$ = = '-h]; then # is help Echo-e ' $USAGE ' elif [D $];
Then dir_name=$ (dirname ${1}) base_name=$ (basename ${1}) GetPath;
Else Echo-e "an invailed argument" echo-e "Use-h get help." Exit $E _invailed_argu fi fi} # Check Work_path Check_work_path () {if [-Z $work _path] | | [!-d $work _path];
Then exit $E _badpath; Fi} # Enter Work_path Enter_work_path () {CD ${work_path} if [! $?]; then echo "Can not enter ${WORK_PA TH} "fi} # Check Work_pat is a svn dir is_svn_dir () {(# Check if the current dir is asvn dir svn info &A
Mp;>/dev/null exit $?
) return $?
Action () {local dir_name=. Local Base_name= local work_path= $dir _name init_work_path $ check_work_path enter_work_path #todo can ' t ent
Er #echo "now dir: $PWD, old dir $OLDPWD" Is_svn_dir #todo to next dir local ret=$?
If [$ret-ne 0] then echo-e "Current dir \ ${work_path}\" Not svn dir. " Exit $E _not_svn_dir fi # get source files local files=$ (LS ${files_type} 2>/dev/null) If [-N "$files" ]; Then local namelist=$ (Echo-n ${files} | xargs-n 1 svn blame | awk ' {print $} ') #svn blame $files #| grep $ | Wc-l statistic_codelines "$namelist" fi local sub_dirs=$ (find-maxdepth 1-type d-name "[^.] *" 2>/dev/null) If [-N "$sub _dirs"]; Then for dir in $sub _dirs;
Do action "$dir" the Done fi CD. Total () {echo "--------totoal----------" echo "NAME | Lines "echo"--------------------------"for coder in $CODER _list; do if [${!coder}-ne 0]; Then printf "%10s | %-7d\n "${coder} ${!coder} fi done echo"--------------------------"} # main echo"-----start counting, please be patient ...:) "Action $ total Exit 0