morganestes
4/23/2014 - 3:42 PM

getprops.sh

#!/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.'