基於git命令的代碼統計方法


基於git命令的代碼統計方法
沒什么好說的,基於git log命令,使用前提是安裝了git ......

1.統計所有人代碼量
統計所有人代碼增刪量,拷貝如下命令,直接在git bash等終端,git項目某分支下執行

git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --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 }' -; done

2.統計指定提交者代碼量
統計單個提交者代碼量,將下面的--author="username" 中的 username 替換成具體的提交者,然后執行

git log --author="username" --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 }' -

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM