统计本地Git仓库中不同贡献者的代码行数的一些方法

简单的查看和统计
1.显示所有贡献者及其commit数

git shortlog –numbered –summary

2.只看某作者提交的commit:

git log –author=”eisneim” –oneline –shortstat

显示行数的统计:

1.Mac,Linux下可以

git log –shortstat –pretty=”%cE” | sed ‘s/\(.*\)@.*/\1/’ | grep -v “^$” | awk ‘BEGIN { line=””; } !/^ / { if (line==”” || !match(line, $0)) {line = $0 “,” line }} /^ / { print line ” # ” $0; line=””}’ | sort | sed -E ‘s/# //;s/ files? changed,//;s/([0-9]+) ([0-9]+ deletion)/\1 0 insertions\(+\), \2/;s/\(\+\)$/\(\+\), 0 deletions\(-\)/;s/insertions?\(\+\), //;s/ deletions?\(-\)//’ | awk ‘BEGIN {name=””; files=0; insertions=0; deletions=0;} {if ($1 != name && name != “”) { print name “: ” files ” 个文件被改变, ” insertions ” 行被插入(+), ” deletions ” 行被删除(-), ” insertions-deletions ” 行剩余”; files=0; insertions=0; deletions=0; name=$1; } name=$1; files+=$2; insertions+=$3; deletions+=$4} END {print name “: ” files ” 个文件被改变, ” insertions ” 行被插入(+), ” deletions ” 行被删除(-), ” insertions-deletions ” 行剩余”;}’

2.使用ruby

git ls-files -z | xargs -0n1 git blame -w | ruby -n -e ‘$_ =~ /^.*\((.*?)\s[\d]{4}/; puts $1.strip’ | sort -f | uniq -c | sort -n

3.统计不同编程语言的行数 这一点不是针对git仓库的,所有的项目都可以,这里我们使用的工具是:cloc (count lines of code)

//mac osx
brew install cloc
// linux 可以用yum或者apt安装,当然也可以自己make install
//使用示例:
cd my_project
cloc ./ –exclude-dir=node_modules,public/lib,public/vendor,public/build –exclude-lang=CSS

非常详细的统计

要想得到非常详细的统计,例如提交时间表,代码随时间的增长曲线等,可以使用gitstats

git clone git://github.com/hoxu/gitstats.git
cd gitstats
./gitstats 你的项目的位置 生成统计的文件夹位置

可能会提示没有安装gnplot画图程序,那么需要安装再执行:

//mac osx
brew install gnplot
//centos linux
yum install gnplot

原文链接:统计本地Git仓库中不同贡献者的代码行数的一些方法

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值