如何获取你在Github项目中写了多少行,以及你写了多少行被删除

1mrurvl1  于 2023-06-20  发布在  Git
关注(0)|答案(2)|浏览(287)

我的上司给了我一个任务,让我找出我在GitHub项目中写了多少行,以及有多少行被删除了。是否有任何内置的方法可以实现这一点?请记住,我不是这个项目的唯一开发人员。我的上司想要证明我的代码不符合标准。

bksxznpy

bksxznpy1#

你需要去页面上的Github项目点击,在顶部栏,去的见解和贡献者后,在左边后。加载后,您将看到每个人的添加(绿色)和删除(红色),这是贡献者添加和删除的行数。

wvyml7n5

wvyml7n52#

我找到了一个解决方案,但可能仍然有一个解决方案,只有一个命令。

git log --shortstat --since="1 year ago" --until="now" \
  | grep "files changed\|Author\|Merge:" \
  | awk '{ \
    if ($1 == "Author:") {\
      currentUser = $2;\
    }\
    if ($2 == "files") {\
      files[currentUser]+=$1;\
      inserted[currentUser]+=$4;\
      deleted[currentUser]+=$6;\
    }\
  } END {\
    for (i in files) {\
      print i ":", "files changed:", files[i], "lines inserted:", inserted[i], "lines deleted:", deleted[i];\
    }\
  }'

相关问题