Skip to content

Instantly share code, notes, and snippets.

@discountry
Created December 27, 2022 13:59
Show Gist options
  • Select an option

  • Save discountry/dd276833eec6a4127117e89b69ff0d43 to your computer and use it in GitHub Desktop.

Select an option

Save discountry/dd276833eec6a4127117e89b69ff0d43 to your computer and use it in GitHub Desktop.
git log --format='%aN' | sort -u | while read name; do echo -en "作者: $name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "添加行数: %s, 删除的行数: %s, 代码总行数: %s\n", add, subs, loc }' -; done
@discountry
Copy link
Author

git ls-files | xargs -n1 git blame --line-porcelain | sed -n 's/^author //p' | sort -f | uniq -ic | sort -nr

@discountry
Copy link
Author

git ls-files -z |
   xargs -0rn 1 -P "$(nproc)" -I{} sh -c 'git blame -w -M -C -C --line-porcelain -- {} | grep -I --line-buffered "^author "' |
   sort -f |
   uniq -ic |
   sort -n

@discountry
Copy link
Author

discountry commented Dec 27, 2022

rankNumber=10
filterNumber=3
cd ./project1
git ls-files | while read f; do git blame -w --line-porcelain -- "$f" | grep -I '^author '; done | sort -f | uniq -ic | sort -k2 -gr > ../rank.txt
cd ../project2
git ls-files | while read f; do git blame -w --line-porcelain -- "$f" | grep -I '^author '; done | sort -f | uniq -ic | sort -k2 -gr | awk "NR<${filterNumber+1}" >> ../rank.txt
cd ../
cat rank.txt | sort -k2 -gr | awk "NR<${rankNumber+1}"

@discountry
Copy link
Author

rankNumber=5

PROJECTS_LIST=('~/project1' '~/project12')

for project in "${PROJECTS_LIST[@]}"
do
  cd $project
  git ls-files | while read f; do git blame -w --line-porcelain -- "$f" | grep -I '^author '; done | sort -f | uniq -ic | sort -k2 -gr >> ~/rank.txt
done

cat ~/rank.txt | sort -k2 -gr | awk "NR<$rankNumber+1"
rm ~/rank.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment