基于Gitlab统计代码行--统计所有仓库、所有提交人的代码总行数(新增加-删除)

公司绩效考核要求,统计GITLAB仓库所有人提示有效代码行业

脚本1: 统计所有仓库、所有提交人的代码总行数(新增加-删除) 脚本2: 统计所有仓库、所有提交人的代码提交汇总与删除汇总 脚本3: 统计指定仓库的所有提交人的代码提交 汇总与删除汇总

注意:所有代码行数为0,统计结果中清除。 所有统计只统计master分支。

安装: 把脚本中的仓库路径搜索修改为GitLab的存储目录。 统计结果存储在/home目录下面。

 

[root@gitlab home]# cat code_statistics.sh
#!/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 '{ loc += $1 -$2 } END { printf loc }'`
#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_end.txt |grep -v '\ 0' > /home/total_all.txt

posted on   net2817  阅读(28050)  评论(5编辑  收藏  举报

编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示