mirror of
https://github.com/jayphelps/git-blame-someone-else.git
synced 2025-04-30 02:26:22 +02:00
added random feature and updated readme accordingly, does not yet get email address
This commit is contained in:
parent
07b4f92f3c
commit
96cf41b9a0
2 changed files with 11 additions and 0 deletions
|
@ -14,6 +14,8 @@ $ sudo make install
|
|||
|
||||
```bash
|
||||
$ git blame-someone-else <author> <commit>
|
||||
OR
|
||||
$ git blame-someone-else "random" <commit>
|
||||
```
|
||||
|
||||

|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue