我在GitHub上有一个存储库,我必须从中找到一些统计数据,然后我必须在Python脚本中处理这些数据。特别地,我必须得到的信息是在一定天数内修改的代码行数,即i e.添加、删除和修改的代码行数。我试着看看GitHub的蜜蜂,但不幸的是我没有找到我需要的东西,有人知道如何建议我该怎么做吗?谢谢
tf7tbtn21#
你可以使用CLOC(“Count Lines of Code”),它会按语言对重要和不重要的代码行进行分类。
cloc $(git ls-files)
git ls-files与xargs cloc相同。或者另一种获得编码行数的方法是使用…
git ls-files
xargs cloc
git ls-files | xargs wc -l
py49o6xq2#
您可以在存储库中使用此命令:
git log --format='%aN' | Sort-Object -Unique | ForEach-Object { $name = $_ $addedLines = 0 $removedLines = 0 (git log --author="$name" --pretty=tformat: --numstat) | ForEach-Object { if ($_ -match '(\d+)\s+(\d+)') { $addedLines += [int]$matches[1] $removedLines += [int]$matches[2] } } [PSCustomObject]@{ Author = $name AddedLines = $addedLines RemovedLines = $removedLines TotalLines = $addedLines - $removedLines }} | Format-Table -AutoSize
git log --format='%aN' | Sort-Object -Unique | ForEach-Object {
$name = $_
$addedLines = 0
$removedLines = 0
(git log --author="$name" --pretty=tformat: --numstat) | ForEach-Object {
if ($_ -match '(\d+)\s+(\d+)') {
$addedLines += [int]$matches[1]
$removedLines += [int]$matches[2]
}
[PSCustomObject]@{
Author = $name
AddedLines = $addedLines
RemovedLines = $removedLines
TotalLines = $addedLines - $removedLines
} | Format-Table -AutoSize
我希望这对你有帮助。
2条答案
按热度按时间tf7tbtn21#
你可以使用CLOC(“Count Lines of Code”),它会按语言对重要和不重要的代码行进行分类。
git ls-files
与xargs cloc
相同。或者另一种获得编码行数的方法是使用…
py49o6xq2#
您可以在存储库中使用此命令:
我希望这对你有帮助。