GitLab代码行数统计--统计增加与删除行数

#!/bin/bash
master_dev='master'
date_star='2018-11-01'
date_end='2018-11-30'
path1=`find /home/gitlab_data/ -name "*.git"`
echo '' > /home/total.txt
#echo $path1
##arr=($a)用于将字符串$a分割到数组$arr ${arr[0]} ${arr[1]} ... 分别存储分割后的数组第1 2 ... 项 ,${arr[@]}存储整个数组。变量$IFS存储着分隔符,这里我们将其设为逗号 "," OLD_IFS用于备份默认的分隔符,使用完后将之恢复默认。
OLD_IFS="$IFS"
IFS=" "
arr=($path1)
IFS="$OLD_IFS"
for s in ${arr[@]}
do

#echo "$s"
cd $s
user1=`git log --pretty='%aN' | sort | uniq `
OLD_IFS="$IFS1"
IFS1=" "
arr1=($user1)
IFS="$OLD_IFS1"
for s1 in ${arr1[@]}
do

#echo "$s1"

# if [[ $s1 != *HEAD* ]]
# then
total=`git log $master_dev --since ==$date_star --until=$date_end --author=$s1 --pretty=tformat: --numstat | awk '{ add += $1;subs += $2 } END { print add,subs }'`
#total_temp1=`git log $master_dev --since ==$date_star --until=$date_end --author='$s1' --pretty=tformat: --numstat | awk '{ printf $1}'`
#echo $total_temp1
# echo '' > /home/total.txt
#if [ -n "$total" ];
#then
echo $s1 $total >> /home/total.txt
#fi
# fi
#user1=`git log --pretty='%aN' | sort | uniq `

done


done


#cat /home/total.txt | awk '{a[$1]+=$2}END{for(i in a)print i,a[i]}' > /home/total_end.txt
cat /home/total.txt | awk '{a[$1]+=$2;b[$1]+=$3}END{for(i in a)print i,a[i],b[i]}' > /home/total_end.txt
echo 'name add_code del_code' > /home/total_all.txt
cat /home/total_end.txt |grep -v '\ 0\ 0' >> /home/total_all.txt

转载于:https://www.cnblogs.com/net2817/p/10044867.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值