svn代码统计

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 [email protected] | awk ‘{print $2}‘ `
list_value=`svn diff -r {$Now_date}:{$next_date} --summarize http://192.168.1.1/svn/project   --username  xiaodx --password [email protected] | 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 [email protected] | 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 [email protected] | awk ‘{print $2}‘ | grep -v "-" | sort | uniq -c
    svn blame -r {$Now_date}:{$next_date}  ${list[$i]}  --username  xiaodx --password [email protected] | awk ‘{print $2}‘ | grep -v "-" | sort | uniq -c >> $0.log
    fi
done

以上是关于svn代码统计的主要内容,如果未能解决你的问题,请参考以下文章

使用项目管理工具对Svn代码查看和统计

使用项目管理工具对Svn代码查看和统计

svn报错cleanup failed–previous operation has not finished; run cleanup if it was interrupted的解决办法(代码片段

SVN代码统计工具StatSVN

svn代码量统计工具StatSVN的使用

有没工具可以统计每个人某个时间段内在svn上提交的代码量。