svn代碼統計
阿新 • • 發佈:2018-05-09
svn代碼統計分享一個自己寫的svn代碼統計的腳本,不喜繞行:
統計項目每個人修改的文件的個數和行數
#!/bin/bash # 統計項目每個人修改的文件的個數和行數 Svn_pro=http://192.168.1.1/svn/project # 版本庫最後修改的信息 Now_date=`date ‘+%F‘` next_date=`date -d "next day" +%Y-%m-%d` #echo -e " 版本庫最後修改信息: " #svn info http://192.168.1.1/svn/project --username username --password password 2>/dev/null | awk ‘NR>6 ‘ (( user_count=${#Svn_user[@]}-1 )) # 修改的文件 #list_value=`svn diff -r {$Now_date}:{$next_date} --summarize http://192.168.1.1/svn/project --username username --password password | awk ‘{print $2}‘ ` list_value=`svn diff -r {$Now_date}:{$next_date} --summarize http://192.168.1.1/svn/project --username username --password password | awk ‘{print $2}‘ ` list=(`echo $list_value`) (( count=${#list[@]}-1 )) for i in `seq 0 $count` do edit=`svn blame -r {$Now_date}:{$next_date} ${list[$i]} --username username --password password | awk ‘{print $2}‘ | grep -v "-" | wc -l` if [ $edit -ne 0 ];then #echo -e "-----------------------------------------------------------------------------------------------" >> $0.log #echo -e "${list[$i]}文件增加行數:" >> $0.log #svn blame -r {$Now_date}:{$next_date} ${list[$i]} --username username --password password | awk ‘{print $2}‘ | grep -v "-" | sort | uniq -c svn blame -r {$Now_date}:{$next_date} ${list[$i]} --username username --password password | awk ‘{print $2}‘ | grep -v "-" | sort | uniq -c >> $0.log fi done #echo -e "Author\t\tTotal lines" awk ‘{sum[$2]+=$1}END{for(c in sum){printf "%-16s%-10s\n",sum[c],c}}‘ $0.log > total #echo "--------------------------------------------------------" #echo -e "Change file\tAuthor" cat $0.log | awk ‘{print $2}‘ | sort | uniq -c > file echo -e "Author Change_file Total_lines" awk ‘NR==FNR{a[i]=$0;i++}NR>FNR{print a[j]" "$0;j++}‘ total file | awk ‘{print $4,$3,$1}‘ rm -f $0.log total file
統計代碼修改的詳情
#!/bin/bash # 統計項目代碼修改的詳情 Svn_pro=http://192.168.1.1/svn/project # 版本庫最後修改的信息 Now_date=`date ‘+%F‘` next_date=`date -d "next day" +%Y-%m-%d` #echo -e " 版本庫最後修改信息: " #svn info http://192.168.1.1/svn/project --username username --password password 2>/dev/null | awk ‘NR>6 ‘ (( user_count=${#Svn_user[@]}-1 )) # 修改的文件 #list_value=`svn diff -r {$Now_date}:{$next_date} --summarize http://192.168.1.1/svn/project --username xiaodx --password Pa@1234 | awk ‘{print $2}‘ ` list_value=`svn diff -r {$Now_date}:{$next_date} --summarize http://192.168.1.1/svn/project --username xiaodx --password Pa@1234 | awk ‘{print $2}‘ ` list=(`echo $list_value`) (( count=${#list[@]}-1 )) for i in `seq 0 $count` do edit=`svn blame -r {$Now_date}:{$next_date} ${list[$i]} --username xiaodx --password Pa@1234 | awk ‘{print $2}‘ | grep -v "-" | wc -l` if [ $edit -ne 0 ];then # echo -e "-----------------------------------------------------------------------------------------------" # echo -e "\033[36m ${list[$i]}t文件增加行數:\033[0m" >> $0.log echo -e "${list[$i]}文件增加行數:" >> $0.log # svn blame -r {$Now_date}:{$next_date} ${list[$i]} --username xiaodx --password Pa@1234 | awk ‘{print $2}‘ | grep -v "-" | sort | uniq -c svn blame -r {$Now_date}:{$next_date} ${list[$i]} --username xiaodx --password Pa@1234 | awk ‘{print $2}‘ | grep -v "-" | sort | uniq -c >> $0.log fi done
svn代碼統計