Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group commits per author #127

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
48 changes: 31 additions & 17 deletions git-standup
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ function colored() {
GIT_PRETTY_DATE="%ad"
fi

GIT_PRETTY_FORMAT="%Cred%h%Creset - %s %Cgreen($GIT_PRETTY_DATE) %C(bold blue)<%an>%Creset"
if [[ $GIT_LOG = "shortlog" ]]; then
GIT_PRETTY_FORMAT="%Cred%h%Creset - %s %Cgreen($GIT_PRETTY_DATE) %Creset"
else
GIT_PRETTY_FORMAT="%Cred%h%Creset - %s %Cgreen($GIT_PRETTY_DATE) %C(bold blue)<%an>%Creset"
fi

COLOR=always

if [[ ${option_g:=} ]]; then
Expand All @@ -71,7 +76,12 @@ function uncolored() {
GIT_PRETTY_DATE="%ad"
fi

GIT_PRETTY_FORMAT="%h - %s ($GIT_PRETTY_DATE) <%an>"
if [[ $GIT_LOG = "shortlog" ]]; then
GIT_PRETTY_FORMAT="%h - %s ($GIT_PRETTY_DATE)"
else
GIT_PRETTY_FORMAT="%h - %s ($GIT_PRETTY_DATE) <%an>"
fi

COLOR=never

if [[ $option_g ]]; then
Expand Down Expand Up @@ -124,9 +134,9 @@ function runStandup() {
fi
}

while getopts "hgfsd:u:a:w:m:D:A:B:LrcRFb:" opt; do
while getopts "hgfsd:u:a:w:m:D:A:B:LrcRFGb:" opt; do
case $opt in
h | d | u | a | w | m | g | D | f | s | L | r | A | B | c | R | F | b)
h | d | u | a | w | m | g | D | f | s | L | r | A | B | c | R | F | G | b)
declare "option_$opt=${OPTARG:-0}"
;;
\?)
Expand All @@ -150,6 +160,21 @@ if [[ ${option_h:=} ]]; then
exit 0
fi

AUTHOR=$(git config user.name)
GIT_LOG="log"

if [[ ${option_a:=} ]]; then
# In case the parameter
if [[ $option_a = 'all' ]]; then
AUTHOR=".*"
if [[ ${option_G:=} ]]; then
GIT_LOG="shortlog"
fi
else
AUTHOR="$option_a"
fi
fi

# Use colors, but only if connected to a terminal, and that terminal supports them.
if [[ -t 1 ]] && [[ -n "$TERM" ]] && command -v tput &> /dev/null && tput colors &> /dev/null; then
ncolors=$(tput colors)
Expand Down Expand Up @@ -263,25 +288,14 @@ for DIR in ${PROJECT_DIRS}; do
if [[ ! -d ".git" || -f ".git" ]]; then
cd "${BASE_DIR}" || exit
continue
fi

AUTHOR=$(git config user.name)

if [[ ${option_a:=} ]]; then
# In case the parameter
if [[ $option_a = 'all' ]]; then
AUTHOR=".*"
else
AUTHOR="$option_a"
fi
fi
fi

GIT_BRANCH_FILTER="--all"
if [[ ${option_b:=} ]]; then
GIT_BRANCH_FILTER="--first-parent $option_b"
fi

GIT_LOG_COMMAND="git --no-pager log \
GIT_LOG_COMMAND="git --no-pager ${GIT_LOG} \
${GIT_BRANCH_FILTER}
--no-merges
--since=\"$SINCE\"
Expand Down