Created
March 19, 2019 15:12
-
-
Save Lovesan/7a1193b65369b3036b8766a9cf8075ab to your computer and use it in GitHub Desktop.
Get your commits for a repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
DATE_START=`date +%Y-%m-01` | |
DATE_END=`date +%Y-%m-%d` | |
USER_NAME=`git config user.name` | |
REPO_DIR=`realpath ./` | |
BRANCH_NAME='origin/master' | |
if [ -t 0 -a -t 1 ]; then | |
echo -n "Enter start date($DATE_START): " | |
read INPUT | |
if [ -n "$INPUT" ]; then | |
DATE_START="$INPUT" | |
fi | |
echo -n "Enter end date($DATE_END): " | |
read INPUT | |
if [ -n "$INPUT" ]; then | |
DATE_END="$INPUT" | |
fi | |
echo -n "Enter user name($USER_NAME): " | |
read INPUT | |
if [ -n "$INPUT" ]; then | |
USER_NAME="$INPUT" | |
fi | |
echo -n "Enter repo directory($REPO_DIR): " | |
read INPUT | |
if [ -n "$INPUT" ]; then | |
REPO_DIR="$INPUT" | |
fi | |
echo -n "Enter branch name($BRANCH_NAME): " | |
read INPUT | |
if [ -n "INPUT" ]; then | |
BRANCH_NAME="$INPUT" | |
fi | |
fi | |
pushd "$REPO_DIR" > /dev/null | |
git fetch --all | |
BY_AUTHOR=`git log --author="$USER_NAME" \ | |
--since="$DATE_START" \ | |
--until="$DATE_END" \ | |
--pretty=format:"%h" \ | |
$BRANCH_NAME` | |
BY_COMMITTER=`git log --committer="$USER_NAME" \ | |
--since="$DATE_START" \ | |
--until="$DATE_END" \ | |
--pretty=format:"%h" \ | |
$BRANCH_NAME` | |
ALL_COMMITS="$BY_AUTHOR $BY_COMMITTER" | |
echo "`echo $ALL_COMMITS | \ | |
tr ' ' '\n' | \ | |
sort -u | \ | |
tr '\n' ',' | \ | |
sed -e 's/,$//g'`" | |
popd > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment