#/bin/sh
file_path="/d/idea/xxx/xxx/"
file_name="../xxx.txt"
function getcodeline() {
git log --since=1.years --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -
return
}
function getcedeperson () {
#查询当前提交人有哪些
personstr=`git log --pretty='%cN' | sort -u`
# OLD_IFS="$IFS"
IFS=$'\n'
arr=($personstr)
# IFS="$OLD_IFS"
for s in ${arr[@]}
do
# echo "提交人-"$s >> $file_name
#查询当前提交人的代码量
# echo `git log --since=1.years --committer=$s --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -` >> $file_name
echo $s":"`git log --since=1.years --committer=$s --pretty=tformat: --numstat | awk '{loc += $1 - $2 } END { printf " %s\n", loc }' -` >> $file_name
done
}
for dir in `ls $1`
do
if test -d $dir
then
arr=(${arr[*]} $dir)
# echo $dir
cd $file_path$dir
echo `pwd`
# echo "项目名称-"$dir >> $file_name
echo "------------------------"$dir"--------------------------------" >> $file_name
echo "总的代码量-"`getcodeline` >> $file_name
getcedeperson
cd ..
fi
done
git代码量统计脚本
最新推荐文章于 2025-07-11 10:42:17 发布