Skip to content

Instantly share code, notes, and snippets.

@djeikyb
Last active October 6, 2022 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djeikyb/0405d82d1674c59edfd2cb5b15bbea7e to your computer and use it in GitHub Desktop.
Save djeikyb/0405d82d1674c59edfd2cb5b15bbea7e to your computer and use it in GitHub Desktop.
A word counter for git messages
#!/bin/sh
countWords() {
commit="$1"
word_count=$(git show --format='%B' --no-patch "$commit" | wc -w)
auth="$(git show --format='%h %aN / %cN' --no-patch $commit)"
echo "$word_count $auth"
exit 0
}
[ -n "$2" ] && countWords "$2"
range="origin/master"
[ -n "$1" ] && range="origin/master~$1..origin/master"
echo "$range"
git log --format='%H' "$range" | xargs -I{} -P 16 $0 --last "{}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment