diff --git a/README.md b/README.md index a9222dc..7ebe509 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ $ sudo make install ```bash $ git blame-someone-else +OR +$ git blame-someone-else "random" ``` ![ezgif-1396449034](https://cloud.githubusercontent.com/assets/762949/12863650/068e2820-cc2e-11e5-80c5-6ebdb71f51ea.gif) diff --git a/git-blame-someone-else b/git-blame-someone-else index d76642c..b953424 100644 --- a/git-blame-someone-else +++ b/git-blame-someone-else @@ -6,6 +6,15 @@ if [ $# -ne 2 ]; then fi AUTHOR=$1 + +if [ "$1" = "random" ]; then + CONTRIBUTORS_RAW=$(git shortlog -s) + CONTRIBUTORS=($CONTRIBUTORS_RAW) + NUM_OF_CONTRIBUTORS=${#CONTRIBUTORS[*]} + RAND_NUM=$(( ( RANDOM % (${#CONTRIBUTORS[*]} / 3) ) * 3 + 1 )) + AUTHOR="${CONTRIBUTORS[$RAND_NUM]} ${CONTRIBUTORS[$RAND_NUM + 1]}" +fi + AUTHOR_NAME=$(echo $AUTHOR | perl -wlne '/^(.*)\s*<.*>$/ and print $1') AUTHOR_EMAIL=$(echo $AUTHOR | perl -wlne '/^.*\s*<(.*)>$/ and print $1') COMMIT=$(git rev-parse --short $2)