Skip to content

Instantly share code, notes, and snippets.

@morganestes
Created April 23, 2014 15:42
Show Gist options
  • Select an option

  • Save morganestes/11220516 to your computer and use it in GitHub Desktop.

Select an option

Save morganestes/11220516 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Get a list of props from the log and search for a given name.
#
# Example: add `getprops <name>` to the end of this file and run
# `$ ./propslog.sh` from the command line.
#
# You can also add this to your ~/.functions file and use
# `getprops <name>` inside your local WordPress Core repo.
#
function getprops() {
if [ -n "$1" ]
then
local name="$1"
else
local name="blamenacin" #default if nothing passed
fi
# build the propslog file
git log -i --grep props | egrep -io 'props (to )?[a-z0-9_\-]*' | sed 's/.* //' | sort | uniq -c | sort -k1nr > propslog.txt
local rank=`grep -inr ${name} propslog.txt | awk '{print $2}' FS=":"`
local total=`wc -l < propslog.txt | tr -d ' '`
# where is our contributor?
grep -i "$name" propslog.txt
echo "$name is $rank of $total named contributors."
}
# git pull
git log -i --grep props | egrep -io 'props (to )?[a-z0-9_\-]*' | sed 's/.* //' | sort | uniq -c | sort -k1nr > propslog.txt
grep -i morganestes propslog.txt
echo 'Ranked' $(awk '/morganestes/ {print FNR}' propslog.txt) 'of' $(wc -l < propslog.txt) 'total contributors.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment