mirror of
https://github.com/git-quick-stats/git-quick-stats.git
synced 2025-12-16 12:00:12 +01:00
Add stats by author per timezone functionality
* Added the ability to see git stats both per timezone, as well as by author per timezone. It should respect all global options. * Adjusted the non-interactive menu as it was missed during the reorganization effort * Updated tests, README.md, man page, and screenshots to reflect the new changes * Resolves #128
This commit is contained in:
12
README.md
12
README.md
@@ -5,7 +5,7 @@
|
||||
>
|
||||
> Any git repository may contain tons of information about commits, contributors, and files. Extracting this information is not always trivial, mostly because there are a gadzillion options to a gadzillion git commands – I don’t think there is a single person alive who knows them all. Probably not even [Linus Torvalds](https://github.com/torvalds) himself :).
|
||||
|
||||

|
||||

|
||||
|
||||
## Table of Contents
|
||||
|
||||
@@ -53,9 +53,9 @@
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
@@ -127,6 +127,10 @@ LIST OPTIONS
|
||||
displays a list of commits per hour
|
||||
-A, --commits-by-author-by-hour
|
||||
displays a list of commits per hour by author
|
||||
-z, --commits-by-timezone
|
||||
displays a list of commits per timezone
|
||||
-Z, --commits-by-author-by-timezone
|
||||
displays a list of commits per timezone by author
|
||||
|
||||
SUGGEST OPTIONS
|
||||
-r, --suggest-reviewers
|
||||
@@ -201,7 +205,7 @@ You can change to the legacy color scheme by toggling the variable `_MENU_THEME`
|
||||
export _MENU_THEME=legacy
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
@@ -160,6 +160,10 @@ LIST OPTIONS
|
||||
displays a list of commits per hour
|
||||
-A, --commits-by-author-by-hour
|
||||
displays a list of commits per hour by author
|
||||
-z, --commits-by-timezone
|
||||
displays a list of commits per timezone
|
||||
-Z, --commits-by-author-by-timezone
|
||||
displays a list of commits per timezone by author
|
||||
|
||||
SUGGEST OPTIONS
|
||||
-r, --suggest-reviewers
|
||||
@@ -237,9 +241,11 @@ function showMenu() {
|
||||
printf %b "${NUMS} 13)${TEXT} Git commits per month\\n"
|
||||
printf %b "${NUMS} 14)${TEXT} Git commits per weekday\\n"
|
||||
printf %b "${NUMS} 15)${TEXT} Git commits per hour\\n"
|
||||
printf %b "${NUMS} 16)${TEXT} Git commits by author per hour\\n"
|
||||
printf %b "${NUMS} 16)${TEXT} Git commits per hour by author\\n"
|
||||
printf %b "${NUMS} 17)${TEXT} Git commits per timezone\\n"
|
||||
printf %b "${NUMS} 18)${TEXT} Git commits per timezone by author\\n"
|
||||
printf %b "\\n${TITLES} Suggest:\\n"
|
||||
printf %b "${NUMS} 17)${TEXT} Code reviewers (based on git history)\\n"
|
||||
printf %b "${NUMS} 19)${TEXT} Code reviewers (based on git history)\\n"
|
||||
printf %b "\\n${HELP_TXT}Please enter a menu option or ${EXIT_TXT}press Enter to exit.\\n"
|
||||
printf %b "${TEXT}> ${NORMAL}"
|
||||
read -r opt
|
||||
@@ -730,6 +736,29 @@ function commitsByHour() {
|
||||
}' | sort
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# DESC: Displays number of commits per timezone
|
||||
# ARGS: $author (optional): Can focus on a single author. Default is all authors
|
||||
# OUTS: None
|
||||
################################################################################
|
||||
function commitsByTimezone() {
|
||||
local author="${1:-}"
|
||||
local _author=""
|
||||
|
||||
if [[ -z "${author}" ]]; then
|
||||
optionPicked "Git commits by timezone:"
|
||||
_author="--author=**"
|
||||
else
|
||||
optionPicked "Git commits by timezone for author '${author}':"
|
||||
_author="--author=${author}"
|
||||
fi
|
||||
|
||||
echo -e "Commits\tTimeZone"
|
||||
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
|
||||
"${_author}" "$_since" "$_until" --date=iso $_log_options $_pathspec \
|
||||
| cut -d " " -f 12 | grep -v -e '^[[:space:]]*$' | sort | uniq -c
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# FUNCTIONS FOR SUGGESTION STATS
|
||||
|
||||
@@ -763,7 +792,7 @@ git rev-parse --is-inside-work-tree > /dev/null
|
||||
# Parse non-interative commands
|
||||
if [[ "$#" -eq 1 ]]; then
|
||||
case "$1" in
|
||||
-r|--suggest-reviewers) suggestReviewers;;
|
||||
# GENERATE OPTIONS
|
||||
-T|--detailed-git-stats) detailedGitStats;;
|
||||
-R|--git-stats-by-branch)
|
||||
branch="${_GIT_BRANCH:-}"
|
||||
@@ -771,18 +800,6 @@ if [[ "$#" -eq 1 ]]; then
|
||||
read -r -p "Which branch? " branch
|
||||
done
|
||||
detailedGitStats "${branch}";;
|
||||
-V|--csv-output-by-branch)
|
||||
branch="${_GIT_BRANCH:-}"
|
||||
while [[ -z "${branch}" ]]; do
|
||||
read -r -p "Which branch? " branch
|
||||
done
|
||||
csvOutput "${branch}";;
|
||||
-b|--branch-tree) branchTree;;
|
||||
-d|--commits-per-day) commitsPerDay;;
|
||||
-a|--commits-per-author) commitsPerAuthor;;
|
||||
-S|--my-daily-stats) myDailyStats;;
|
||||
-C|--contributors) contributors;;
|
||||
-D|--branches-by-date) branchesByDate;;
|
||||
-c|--changelogs) changelogs;;
|
||||
-L|--changelogs-by-author)
|
||||
author="${_GIT_AUTHOR:-}"
|
||||
@@ -790,15 +807,13 @@ if [[ "$#" -eq 1 ]]; then
|
||||
read -r -p "Which author? " author
|
||||
done
|
||||
changelogs "${author}";;
|
||||
-w|--commits-by-weekday) commitsByWeekday;;
|
||||
-o|--commits-by-hour) commitsByHour;;
|
||||
-A|--commits-by-author-by-hour)
|
||||
author="${_GIT_AUTHOR:-}"
|
||||
while [[ -z "${author}" ]]; do
|
||||
read -r -p "Which author? " author
|
||||
-S|--my-daily-stats) myDailyStats;;
|
||||
-V|--csv-output-by-branch)
|
||||
branch="${_GIT_BRANCH:-}"
|
||||
while [[ -z "${branch}" ]]; do
|
||||
read -r -p "Which branch? " branch
|
||||
done
|
||||
commitsByHour "${author}";;
|
||||
-m|--commits-by-month) commitsByMonth;;
|
||||
csvOutput "${branch}";;
|
||||
-j|--json-output)
|
||||
json_path=""
|
||||
while [[ -z "${json_path}" ]]; do
|
||||
@@ -817,6 +832,30 @@ if [[ "$#" -eq 1 ]]; then
|
||||
fi
|
||||
done
|
||||
jsonOutput "${json_path}";;
|
||||
# LIST OPTIONS
|
||||
-b|--branch-tree) branchTree;;
|
||||
-D|--branches-by-date) branchesByDate;;
|
||||
-C|--contributors) contributors;;
|
||||
-a|--commits-per-author) commitsPerAuthor;;
|
||||
-d|--commits-per-day) commitsPerDay;;
|
||||
-m|--commits-by-month) commitsByMonth;;
|
||||
-w|--commits-by-weekday) commitsByWeekday;;
|
||||
-o|--commits-by-hour) commitsByHour;;
|
||||
-A|--commits-by-author-by-hour)
|
||||
author="${_GIT_AUTHOR:-}"
|
||||
while [[ -z "${author}" ]]; do
|
||||
read -r -p "Which author? " author
|
||||
done
|
||||
commitsByHour "${author}";;
|
||||
-z|--commits-by-timezone) commitsByTimezone;;
|
||||
-Z|--commits-by-author-by-timezone)
|
||||
author="${_GIT_AUTHOR:-}"
|
||||
while [[ -z "${author}" ]]; do
|
||||
read -r -p "Which author? " author
|
||||
done
|
||||
commitsByTimezone "${author}";;
|
||||
# SUGGEST OPTIONS
|
||||
-r|--suggest-reviewers) suggestReviewers;;
|
||||
-h|-\?|--help) usage;;
|
||||
*) echo "Invalid argument"; usage; exit 1;;
|
||||
esac
|
||||
@@ -879,7 +918,13 @@ while [[ "${opt}" != "" ]]; do
|
||||
read -r -p "Which author? " author
|
||||
done
|
||||
commitsByHour "${author}"; showMenu;;
|
||||
17) suggestReviewers; showMenu;;
|
||||
17) commitsByTimezone; showMenu;;
|
||||
18) author=""
|
||||
while [[ -z "${author}" ]]; do
|
||||
read -r -p "Which author? " author
|
||||
done
|
||||
commitsByTimezone "${author}"; showMenu;;
|
||||
19) suggestReviewers; showMenu;;
|
||||
q|"\n") exit;;
|
||||
*) clear; optionPicked "Pick an option from the menu"; showMenu;;
|
||||
esac
|
||||
|
||||
@@ -99,6 +99,16 @@ displays a list of commits per hour
|
||||
.IP
|
||||
displays a list of commits per hour by author
|
||||
.HP
|
||||
.PP
|
||||
\fB\-z\fR, \fB\-\-commits\-by\-timezone\fR
|
||||
.IP
|
||||
displays a list of commits per timezone
|
||||
.HP
|
||||
.PP
|
||||
\fB\-Z\fR, \fB\-\-commits\-by\-author\-by\-timezone\fR
|
||||
.IP
|
||||
displays a list of commits per timezone by author
|
||||
.HP
|
||||
.SH SUGGEST OPTIONS
|
||||
.PP
|
||||
\fB\-r\fR, \fB\-\-suggest\-reviewers\fR
|
||||
|
||||
@@ -54,6 +54,10 @@ LIST OPTIONS
|
||||
displays a list of commits per hour
|
||||
-A, --commits-by-author-by-hour
|
||||
displays a list of commits per hour by author
|
||||
-z, --commits-by-timezone
|
||||
displays a list of commits per timezone
|
||||
-Z, --commits-by-author-by-timezone
|
||||
displays a list of commits per timezone by author
|
||||
|
||||
SUGGEST OPTIONS
|
||||
-r, --suggest-reviewers
|
||||
|
||||
Reference in New Issue
Block a user