Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ $ sudo make install

```bash
$ git blame-someone-else <author> <commit>
OR
$ git blame-someone-else "random" <commit>
```

![ezgif-1396449034](https://cloud.githubusercontent.com/assets/762949/12863650/068e2820-cc2e-11e5-80c5-6ebdb71f51ea.gif)
Expand Down
9 changes: 9 additions & 0 deletions git-blame-someone-else
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down