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 是否提供任何功能来排除文件?

4

3 回答 3

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

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

  2. 对于每个commit,列出所有更改的文件,不包括一些文件/文件夹。

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

  3. 对于其余的每个文件,计算其insertions和。deletionsdelta

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

  4. 总结结果。

于 2017-09-13T12:30:32.423 回答
0

我发现这样做的最好方法是使用 cloc 并让它忽略源代码控制忽略的相同文件。

前任:

cloc --vcs=git .

于 2020-12-14T13:20:31.680 回答
0

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

简而言之,--exclude-list-file允许您传入包含要排除的文件名的文件,--exclude-dir允许您跳过指定的目录,--exclude-ext跳过具有给定文件扩展名的文件,--exclude-lang忽略给定的编程语言,--not-match-f允许您指定跳过匹配项的正则表达式。

于 2017-09-14T03:21:40.977 回答