svn code statistics

Share a script for svn code statistics written by yourself, don't like to go around:

Count the number and lines of files modified by each person in the project

#!/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

Details of Stats Code Modifications

#!/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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326438418&siteId=291194637