2017-09-13 59 views
0

我有一个用户案例,我需要计算每个BUC-ID的代码行数。 我一直在使用如何在计算代码行时跳过特定的文件?

  git log --shortstat --grep=BUC3565-EPIC16 |grep -E "fil(e|es) changed" | awk -v BUC=$i '{ inserted+=$4; deleted+=$6; delta+=$4-$6i } END {printf "%s, %s, %s, %s \n",BUC, inserted, deleted, delta }' 

现在我有BUC-ID与多个文件实现相同。有没有什么办法可以跳过几个文件/文件夹,并且仍然能够计算该BUC-ID的线路关闭代码?

Basically, I need to exclude some files/folders while calculating Lines of Code. I am not able to do so because each commit has multiple files. Some should be included and some excluded...Any idea how to achieve that? 

CLOC是否提供排除文件的功能?

回答

0
  1. 查找所有与BUC-ID相关的提交。

    git log --pretty=%H --grep=BUC3565-EPIC16

  2. 提交,列出所有修改过的文件排除某些文件/文件夹。

    git show $commit --pretty=format:"" --name-only | grep -ve "foo.txt" -ve "bar/"

  3. 对于剩下的每文件,计算出其insertionsdeletionsdelta

    git show $commit --pretty=format:"" --short-stat -- $file | grep -E "fil(e|es) changed" | awk

  4. 总结的结果。

0

cloc有几种排除文件的机制;有关详细信息,请在 https://github.com/AlDanial/cloc上搜索“排除”。

简而言之,--exclude-list-file让您在包含文件名的文件,你想排除通过,--exclude-dir,您可以跳过指定的目录,--exclude-ext跳过与给定文件扩展名的文件,--exclude-lang忽略给定的编程语言,--not-match-f让你指定一个正则表达式其比赛被跳过。