按作者搜索git历史记录和组
假设我想数一数有多少按作者搜索git历史记录和组,git,Git,假设我想数一数有多少语句被提交,然后按作者分组,我该怎么做 我想做的示例: git count-by-author "if (" 245 Author A 199 Author B 20 Author C 我主要感兴趣的是引入的if语句的数量,如果可能的话,不修改if语句。没有纯git解决方案,但您可以使用以下bash脚本来获得此类统计信息: for sha in $(git log --format=%H); do author="$(git show --format=%an
语句被提交,然后按作者分组,我该怎么做
我想做的示例:
git count-by-author "if ("
245 Author A
199 Author B
20 Author C
我主要感兴趣的是引入的if
语句的数量,如果可能的话,不修改if
语句。没有纯git解决方案,但您可以使用以下bash脚本来获得此类统计信息:
for sha in $(git log --format=%H); do
author="$(git show --format=%an $sha | head -n1)"
removed_if_statements=$(git show $sha | grep -E '^\-(.* )?if \(' | wc -l)
added_if_statements=$(git show $sha | grep -E '^\+(.* )?if \(' | wc -l)
delta=$(( $added_if_statements - $removed_if_statements ))
if [ $delta -gt 0 ]; then
for x in $(seq 1 $delta); do
echo $author
done
fi
done | sort | uniq -c | sort -rg
美好的只需将-g添加到最后的排序中
即可正确排序(例如,在1100之前对8进行了排序),而且,这一行似乎需要zsh`表示{1..$delta}中的x;do`显然{1..5}
在bash中工作,但是var=5;{1..$var}
仅在zsh中工作。我没有意识到这一点。我又更新了答案。