统计分析svn用户每天提交的代码数

这个脚本可以分析svn 用户每天提交的代码数,有了数量的横向比较,也就知道团队里面哪个成员是有很大的潜力提升,帮助其提高。

可以在这里https://gist.github.com/1297604获取最新的代码,复制黏贴到文件里面,chmod +x 后,即可使用。

使用方法:

像下面,获取上一天某账号改动代码的数量

./svn_ana.sh SVN_ACCOUNT_NAME | wc -l

这里也附上代码,使用前将uname, password用你svn账号的用户名、密码替换

#!/bin/sh
# This is a script that help you get your team member's productivity
# by analyzing his/her code commiting in SVN repository, for the day before
#
# You can get a rough num for comparing between team members by using it in the way below
# ./svn_ana.sh SVN_ACCOUNT_NAME | wc -l
#
uname=vr
password=reader

if [ $# -lt 1 ]
then
	echo Usage: $0 ACCOUNT
	echo -e "   Where ACCOUNT is the SVN acconut name you want to analyze"
	exit -1
fi
user=$1
today=`date +%Y-%m-%d`
yesterday=`date -d '-1 day'  +%Y-%m-%d`
revisions=$(svn log -r{$today}:{$yesterday} --username $uname --password $password |grep $user'\ '|awk '{print $1}')
lastrev=init
for rawrev in $revisions
do
	rev=$(echo $rawrev|tr -d r)
	rev2=`expr $rev - 1`
	if [ "$lastrev" = "init" ]; then
		lastrev=$rev
	fi
	dummy=$(echo $revisions|grep $rev2)
	if [ $? -eq 0 ]
	then
		continue
	fi

	svn diff -r$rev2:$lastrev --username $uname --password $password
	lastrev=init
done

您也许对以下文章感兴趣