mirror of
https://github.com/git-quick-stats/git-quick-stats.git
synced 2025-12-16 12:00:12 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
255f1a6976 | ||
|
|
2cc5cae1a8 | ||
|
|
4f95691967 | ||
|
|
36405591ec | ||
|
|
4e3f4ba826 | ||
|
|
83e96f8b80 | ||
|
|
206ebd8a76 | ||
|
|
2274ca1284 | ||
|
|
37f15f6381 | ||
|
|
337ead38e3 | ||
|
|
c38e4eb7b6 | ||
|
|
b767822eb3 |
42
README.md
42
README.md
@@ -59,10 +59,40 @@ Or you can use (non-interactive) direct execution:
|
|||||||
|
|
||||||
`git quick-stats <optional-command-to-execute-directly>`
|
`git quick-stats <optional-command-to-execute-directly>`
|
||||||
|
|
||||||
Possible arguments:
|
Possible arguments in short and long form:
|
||||||
> suggestReviewers, detailedGitStats, commitsByHour, commitsByWeekday, commitsByMonth, commitsPerDay, commitsPerAuthor, myDailyStats, contributors,
|
|
||||||
branchTree, branchesByDate, changelogs, changelogsByAuthor
|
|
||||||
|
|
||||||
|
```
|
||||||
|
-r, --suggest-reviewers
|
||||||
|
show the best people to contact to review code
|
||||||
|
-T, --detailed-git-stats
|
||||||
|
give a detailed list of git stats
|
||||||
|
-d, --commits-per-day
|
||||||
|
displays a list of commits per day
|
||||||
|
-m, --commits-by-month
|
||||||
|
displays a list of commits per month
|
||||||
|
-w, --commits-by-weekday
|
||||||
|
displays a list of commits per weekday
|
||||||
|
-o, --commits-by-hour
|
||||||
|
displays a list of commits per hour
|
||||||
|
-A, --commits-by-author-by-hour
|
||||||
|
displays a list of commits per hour by author
|
||||||
|
-a, --commits-per-author
|
||||||
|
displays a list of commits per author
|
||||||
|
-S, --my-daily-stats
|
||||||
|
see your current daily stats
|
||||||
|
-C, --contributors
|
||||||
|
see a list of everyone who contributed to the repo
|
||||||
|
-b, --branch-tree
|
||||||
|
show an ASCII graph of the git repo branch history
|
||||||
|
-D, --branches-by-date
|
||||||
|
show branches by date
|
||||||
|
-c, --changelogs
|
||||||
|
see changelogs
|
||||||
|
-L, --changelogs-by-author
|
||||||
|
see changelogs by author
|
||||||
|
-h, -?, --help
|
||||||
|
display this help text in the terminal
|
||||||
|
```
|
||||||
|
|
||||||
#### Git log since / until
|
#### Git log since / until
|
||||||
|
|
||||||
@@ -129,7 +159,7 @@ brew install git-quick-stats
|
|||||||
## System requirements
|
## System requirements
|
||||||
|
|
||||||
* Unix like OS with a proper shell
|
* Unix like OS with a proper shell
|
||||||
* Tools we use: git ; awk ; sed ; tr ; echo ; grep ; cut ; sort ; head ; uniq ; column.
|
* Tools we use: awk ; cat ; column ; echo ; git ; grep ; head ; seq ; sort ; tput ; tr ; uniq ; wc
|
||||||
|
|
||||||
#### Dependences
|
#### Dependences
|
||||||
|
|
||||||
@@ -146,11 +176,11 @@ brew install git-quick-stats
|
|||||||
Want to contribute? Great! First, read this page.
|
Want to contribute? Great! First, read this page.
|
||||||
|
|
||||||
#### Code reviews
|
#### Code reviews
|
||||||
All submissions, including submissions by project members, require review.
|
All submissions, including submissions by project members, require review.</br>
|
||||||
We use Github pull requests for this purpose.
|
We use Github pull requests for this purpose.
|
||||||
|
|
||||||
#### Some tips for good pull requests:
|
#### Some tips for good pull requests:
|
||||||
* Use our code
|
* Use our code </br>
|
||||||
When in doubt, try to stay true to the existing code of the project.
|
When in doubt, try to stay true to the existing code of the project.
|
||||||
* Write a descriptive commit message. What problem are you solving and what
|
* Write a descriptive commit message. What problem are you solving and what
|
||||||
are the consequences? Where and what did you test? Some good tips:
|
are the consequences? Where and what did you test? Some good tips:
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||||
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
<meta http-equiv="refresh" content="0;url=https://lukasmestan.com/git-quick-stats/">
|
||||||
</head>
|
</head>
|
||||||
<body id="page-top">
|
<body id="page-top">
|
||||||
<header>
|
<header>
|
||||||
|
|||||||
424
git-quick-stats
424
git-quick-stats
@@ -4,70 +4,140 @@ set -o nounset
|
|||||||
set -o errexit
|
set -o errexit
|
||||||
|
|
||||||
_since=${_GIT_SINCE:-}
|
_since=${_GIT_SINCE:-}
|
||||||
if [ ! -z ${_since} ]
|
[[ -n "${_since}" ]] && _since="--since=$_since"
|
||||||
then _since="--since=$_since"
|
|
||||||
fi
|
|
||||||
|
|
||||||
_until=${_GIT_UNTIL:-}
|
_until=${_GIT_UNTIL:-}
|
||||||
if [ ! -z ${_until} ]
|
[[ -n "${_until}" ]] && _until="--until=$_until"
|
||||||
then _until="--until=$_until"
|
|
||||||
fi
|
|
||||||
|
|
||||||
_pathspec=${_GIT_PATHSPEC:-}
|
_pathspec=${_GIT_PATHSPEC:-}
|
||||||
if [ ! -z "${_pathspec}" ]
|
[[ -n "${_pathspec}" ]] && _pathspec="-- $_pathspec"
|
||||||
then _pathspec="-- $_pathspec"
|
|
||||||
fi
|
|
||||||
|
|
||||||
_limit=${_GIT_LIMIT:-}
|
_limit=${_GIT_LIMIT:-}
|
||||||
if [ ! -z ${_limit} ]
|
if [[ -n "${_limit}" ]];
|
||||||
then _limit=$_limit
|
then _limit=$_limit
|
||||||
else
|
else
|
||||||
_limit=10
|
_limit=10
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function show_menu() {
|
function check_utils() {
|
||||||
NORMAL=`echo "\033[m"`
|
local HELP_MSG="not found. Please make sure this is installed and in PATH."
|
||||||
MENU=`echo "\033[36m"`
|
|
||||||
NUMBER=`echo "\033[33m"`
|
|
||||||
FGRED=`echo "\033[41m"`
|
|
||||||
RED_TEXT=`echo "\033[31m"`
|
|
||||||
ENTER_LINE=`echo "\033[33m"`
|
|
||||||
|
|
||||||
echo -e ""
|
command -v awk >/dev/null 2>&1 || { echo >&2 "awk ${HELP_MSG}"; exit 1; }
|
||||||
echo -e "${RED_TEXT} Generate: ${NORMAL}"
|
command -v basename >/dev/null 2>&1 || { echo >&2 "basename ${HELP_MSG}"; exit 1; }
|
||||||
echo -e "${MENU} ${NUMBER} 1)${MENU} Contribution stats (by author) ${NORMAL}"
|
command -v cat > /dev/null 2>&1 || { echo >&2 "cat ${HELP_MSG}"; exit 1; }
|
||||||
echo -e "${MENU} ${NUMBER} 2)${MENU} Git changelogs (last $_limit days)${NORMAL}"
|
command -v column > /dev/null 2>&1 || { echo >&2 "column ${HELP_MSG}"; exit 1; }
|
||||||
echo -e "${MENU} ${NUMBER} 3)${MENU} Git changelogs by author ${NORMAL}"
|
command -v echo > /dev/null 2>&1 || { echo >&2 "echo ${HELP_MSG}"; exit 1; }
|
||||||
echo -e "${MENU} ${NUMBER} 4)${MENU} My daily status ${NORMAL}"
|
command -v git > /dev/null 2>&1 || { echo >&2 "git ${HELP_MSG}"; exit 1; }
|
||||||
|
command -v grep > /dev/null 2>&1 || { echo >&2 "grep ${HELP_MSG}"; exit 1; }
|
||||||
|
command -v head > /dev/null 2>&1 || { echo >&2 "head ${HELP_MSG}"; exit 1; }
|
||||||
|
command -v seq > /dev/null 2>&1 || { echo >&2 "seq ${HELP_MSG}"; exit 1; }
|
||||||
|
command -v sort > /dev/null 2>&1 || { echo >&2 "sort ${HELP_MSG}"; exit 1; }
|
||||||
|
command -v tput > /dev/null 2>&1 || { echo >&2 "tput ${HELP_MSG}"; exit 1; }
|
||||||
|
command -v tr > /dev/null 2>&1 || { echo >&2 "tr ${HELP_MSG}"; exit 1; }
|
||||||
|
command -v uniq > /dev/null 2>&1 || { echo >&2 "uniq ${HELP_MSG}"; exit 1; }
|
||||||
|
command -v wc > /dev/null 2>&1 || { echo >&2 "wc ${HELP_MSG}"; exit 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
local program=$(basename "$0")
|
||||||
|
|
||||||
|
echo "
|
||||||
|
NAME
|
||||||
|
${program} - Simple and efficient way to access various stats in a git repo
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
For non-interactive mode: ${program} [OPTIONS]
|
||||||
|
For interactive mode: ${program}
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
Any git repository contains tons of information about commits, contributors,
|
||||||
|
and files. Extracting this information is not always trivial, mostly because
|
||||||
|
of a gadzillion options to a gadzillion git commands.
|
||||||
|
|
||||||
|
This program allows you to see detailed information about a git repository.
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-r, --suggest-reviewers
|
||||||
|
show the best people to contact to review code
|
||||||
|
-T, --detailed-git-stats
|
||||||
|
give a detailed list of git stats
|
||||||
|
-d, --commits-per-day
|
||||||
|
displays a list of commits per day
|
||||||
|
-m, --commits-by-month
|
||||||
|
displays a list of commits per month
|
||||||
|
-w, --commits-by-weekday
|
||||||
|
displays a list of commits per weekday
|
||||||
|
-o, --commits-by-hour
|
||||||
|
displays a list of commits per hour
|
||||||
|
-A, --commits-by-author-by-hour
|
||||||
|
displays a list of commits per hour by author
|
||||||
|
-a, --commits-per-author
|
||||||
|
displays a list of commits per author
|
||||||
|
-S, --my-daily-stats
|
||||||
|
see your current daily stats
|
||||||
|
-C, --contributors
|
||||||
|
see a list of everyone who contributed to the repo
|
||||||
|
-b, --branch-tree
|
||||||
|
show an ASCII graph of the git repo branch history
|
||||||
|
-D, --branches-by-date
|
||||||
|
show branches by date
|
||||||
|
-c, --changelogs
|
||||||
|
see changelogs
|
||||||
|
-L, --changelogs-by-author
|
||||||
|
see changelogs by author
|
||||||
|
-h, -?, --help
|
||||||
|
display this help text in the terminal
|
||||||
|
|
||||||
|
ADDITIONAL USAGE
|
||||||
|
You can set _GIT_SINCE and _GIT_UNTIL to limit the git time log
|
||||||
|
ex: export _GIT_SINCE=\"2017-20-01\"
|
||||||
|
You can set _GIT_LIMIT for limited output log
|
||||||
|
ex: export _GIT_LIMIT=20
|
||||||
|
You can exclude a directory from the stats by using pathspec
|
||||||
|
ex: export _GIT_PATHSPEC=':!directory'"
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_menu() {
|
||||||
|
local NORMAL=$(tput sgr0)
|
||||||
|
local CYAN_TEXT=$(tput setaf 6)
|
||||||
|
local RED_TEXT=$(tput setaf 1)
|
||||||
|
local YELLOW_TEXT=$(tput setaf 3)
|
||||||
|
|
||||||
|
echo -e "\n${RED_TEXT} Generate: ${NORMAL}"
|
||||||
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 1)${CYAN_TEXT} Contribution stats (by author) ${NORMAL}"
|
||||||
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 2)${CYAN_TEXT} Git changelogs (last $_limit days)${NORMAL}"
|
||||||
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 3)${CYAN_TEXT} Git changelogs by author ${NORMAL}"
|
||||||
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 4)${CYAN_TEXT} My daily status ${NORMAL}"
|
||||||
echo -e "${RED_TEXT} List: ${NORMAL}"
|
echo -e "${RED_TEXT} List: ${NORMAL}"
|
||||||
echo -e "${MENU} ${NUMBER} 5)${MENU} Branch tree view (last $_limit)${NORMAL}"
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 5)${CYAN_TEXT} Branch tree view (last $_limit)${NORMAL}"
|
||||||
echo -e "${MENU} ${NUMBER} 6)${MENU} All branches (sorted by most recent commit) ${NORMAL}"
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 6)${CYAN_TEXT} All branches (sorted by most recent commit) ${NORMAL}"
|
||||||
echo -e "${MENU} ${NUMBER} 7)${MENU} All contributors (sorted by name) ${NORMAL}"
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 7)${CYAN_TEXT} All contributors (sorted by name) ${NORMAL}"
|
||||||
echo -e "${MENU} ${NUMBER} 8)${MENU} Git commits per author ${NORMAL}"
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 8)${CYAN_TEXT} Git commits per author ${NORMAL}"
|
||||||
echo -e "${MENU} ${NUMBER} 9)${MENU} Git commits per date ${NORMAL}"
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 9)${CYAN_TEXT} Git commits per date ${NORMAL}"
|
||||||
echo -e "${MENU} ${NUMBER} 10)${MENU} Git commits per month ${NORMAL}"
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 10)${CYAN_TEXT} Git commits per month ${NORMAL}"
|
||||||
echo -e "${MENU} ${NUMBER} 11)${MENU} Git commits per weekday ${NORMAL}"
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 11)${CYAN_TEXT} Git commits per weekday ${NORMAL}"
|
||||||
echo -e "${MENU} ${NUMBER} 12)${MENU} Git commits per hour ${NORMAL}"
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 12)${CYAN_TEXT} Git commits per hour ${NORMAL}"
|
||||||
echo -e "${MENU} ${NUMBER} 13)${MENU} Git commits by author per hour ${NORMAL}"
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 13)${CYAN_TEXT} Git commits by author per hour ${NORMAL}"
|
||||||
echo -e "${RED_TEXT} Suggest: ${NORMAL}"
|
echo -e "${RED_TEXT} Suggest: ${NORMAL}"
|
||||||
echo -e "${MENU} ${NUMBER} 14)${MENU} Code reviewers (based on git history) ${NORMAL}"
|
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 14)${CYAN_TEXT} Code reviewers (based on git history) ${NORMAL}"
|
||||||
echo -e ""
|
echo -e "\n${YELLOW_TEXT}Please enter a menu option or ${RED_TEXT}press enter to exit. ${NORMAL}"
|
||||||
echo -e "${ENTER_LINE}Please enter a menu option or ${RED_TEXT}press enter to exit. ${NORMAL}"
|
read -r opt
|
||||||
read opt
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function option_picked() {
|
function option_picked() {
|
||||||
COLOR='\033[01;31m'
|
local BOLD=$(tput bold)
|
||||||
RESET='\033[00;00m'
|
local RED_TEXT=$(tput setaf 1)
|
||||||
MESSAGE=${@:-"${RESET}Error: No message passed"}
|
local COLOR="${BOLD}${RED_TEXT}"
|
||||||
echo -e "${COLOR}${MESSAGE}${RESET}"
|
local RESET=$(tput sgr0)
|
||||||
echo ""
|
local MESSAGE=${*:-"${RESET}Error: No message passed"}
|
||||||
|
|
||||||
|
echo -e "${COLOR}${MESSAGE}${RESET}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
function detailedGitStats() {
|
function detailedGitStats() {
|
||||||
option_picked "Contribution stats (by author):"
|
option_picked "Contribution stats (by author):"
|
||||||
|
git log --use-mailmap --no-merges --numstat --pretty="format:commit %H%nAuthor: %aN <%aE>%nDate: %ad%n%n%w(0,4,4)%B%n" $_since $_until $_pathspec | LC_ALL=C awk '
|
||||||
git log --use-mailmap --no-merges --numstat --pretty="format:commit %H%nAuthor: %aN <%ae>%nDate: %ad%n%n%w(0,4,4)%B%n" $_since $_until $_pathspec | LC_ALL=C awk '
|
|
||||||
function printStats(author) {
|
function printStats(author) {
|
||||||
printf "\t%s:\n", author
|
printf "\t%s:\n", author
|
||||||
|
|
||||||
@@ -84,7 +154,7 @@ function detailedGitStats() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(commits["total"] > 0) {
|
if(commits["total"] > 0) {
|
||||||
printf "\t commits: %d (%.0f%%)\n", commits[author], (commits[author] / commits["total"] * 100)
|
printf "\t commits: %d (%.0f%%)\n", commits[author], (commits[author] / commits["total"] * 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( first[author] != "" ) {
|
if ( first[author] != "" ) {
|
||||||
@@ -146,7 +216,7 @@ function commitsByMonth() {
|
|||||||
for i in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
|
for i in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
|
||||||
do
|
do
|
||||||
echo -en "\t$i\t"
|
echo -en "\t$i\t"
|
||||||
echo $(git shortlog -n --no-merges --format='%ad %s' $_since $_until | grep " $i " | wc -l)
|
git shortlog -n --no-merges --format='%ad %s' $_since $_until | grep " $i " | wc -l
|
||||||
done | awk '{
|
done | awk '{
|
||||||
count[$1] = $2
|
count[$1] = $2
|
||||||
total += $2
|
total += $2
|
||||||
@@ -154,12 +224,13 @@ function commitsByMonth() {
|
|||||||
END{
|
END{
|
||||||
for (month in count) {
|
for (month in count) {
|
||||||
s="|";
|
s="|";
|
||||||
percent = ((count[month] / total) * 100) / 1.25;
|
if (total > 0) {
|
||||||
for (i = 1; i <= percent; ++i) {
|
percent = ((count[month] / total) * 100) / 1.25;
|
||||||
s=s"█"
|
for (i = 1; i <= percent; ++i) {
|
||||||
|
s=s"█"
|
||||||
|
}
|
||||||
|
printf( "\t%s\t%-0s\t%s\n", month, count[month], s );
|
||||||
}
|
}
|
||||||
|
|
||||||
printf( "\t%s\t%-0s\t%s\n", month, count[month], s );
|
|
||||||
}
|
}
|
||||||
}' | LC_TIME="en_EN.UTF-8" sort -M
|
}' | LC_TIME="en_EN.UTF-8" sort -M
|
||||||
}
|
}
|
||||||
@@ -170,7 +241,7 @@ function commitsByWeekday() {
|
|||||||
for i in Mon Tue Wed Thu Fri Sat Sun
|
for i in Mon Tue Wed Thu Fri Sat Sun
|
||||||
do
|
do
|
||||||
echo -en "\t$i\t"
|
echo -en "\t$i\t"
|
||||||
echo $(git shortlog -n --no-merges --format='%ad %s' $_since $_until | grep "$i " | wc -l)
|
git shortlog -n --no-merges --format='%ad %s' $_since $_until | grep "$i " | wc -l
|
||||||
done | awk '{
|
done | awk '{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -183,29 +254,33 @@ function commitsByWeekday() {
|
|||||||
|
|
||||||
for (day in count) {
|
for (day in count) {
|
||||||
s="|";
|
s="|";
|
||||||
percent = ((count[day] / total) * 100) / 1.25;
|
if (total > 0) {
|
||||||
for (i = 1; i <= percent; ++i) {
|
percent = ((count[day] / total) * 100) / 1.25;
|
||||||
s=s"█"
|
for (i = 1; i <= percent; ++i) {
|
||||||
|
s=s"█"
|
||||||
|
}
|
||||||
|
printf( "\t%s\t%-0s\t%s\n", day, count[day], s );
|
||||||
}
|
}
|
||||||
printf( "\t%s\t%-0s\t%s\n", day, count[day], s );
|
|
||||||
}
|
}
|
||||||
}' | sort -k 2 -n -r
|
}' | sort -k 2 -n -r
|
||||||
}
|
}
|
||||||
|
|
||||||
function commitsByHour() {
|
function commitsByHour() {
|
||||||
local author="${1:-}"
|
local author="${1:-}"
|
||||||
local _author=''
|
local _author=""
|
||||||
if [ -z "$author" ]; then
|
|
||||||
|
if [[ -z "${author}" ]]; then
|
||||||
option_picked "Git commits by hour:"
|
option_picked "Git commits by hour:"
|
||||||
|
_author="--author=**"
|
||||||
else
|
else
|
||||||
option_picked "Git commits by hour for author '$author':"
|
option_picked "Git commits by hour for author '${author}':"
|
||||||
_author="--author=$author"
|
_author="--author=${author}"
|
||||||
fi
|
fi
|
||||||
echo -e "\thour\tsum"
|
echo -e "\thour\tsum"
|
||||||
for i in `seq -w 0 23`
|
for i in $(seq -w 0 23)
|
||||||
do
|
do
|
||||||
echo -ne "\t$i\t"
|
echo -ne "\t$i\t"
|
||||||
echo "$(git shortlog -n --no-merges --format='%ad %s' $_author $_since $_until | grep ' '$i: | wc -l)"
|
git shortlog -n --no-merges --format='%ad %s' "${_author}" $_since $_until | grep ' '$i: | wc -l
|
||||||
done | awk '{
|
done | awk '{
|
||||||
count[$1] = $2
|
count[$1] = $2
|
||||||
total += $2
|
total += $2
|
||||||
@@ -213,11 +288,13 @@ function commitsByHour() {
|
|||||||
END{
|
END{
|
||||||
for (hour in count) {
|
for (hour in count) {
|
||||||
s="|";
|
s="|";
|
||||||
percent = ((count[hour] / total) * 100) / 1.25;
|
if (total > 0) {
|
||||||
for (i = 1; i <= percent; ++i) {
|
percent = ((count[hour] / total) * 100) / 1.25;
|
||||||
s=s"█"
|
for (i = 1; i <= percent; ++i) {
|
||||||
|
s=s"█"
|
||||||
|
}
|
||||||
|
printf( "\t%s\t%-0s\t%s\n", hour, count[hour], s );
|
||||||
}
|
}
|
||||||
printf( "\t%s\t%-0s\t%s\n", hour, count[hour], s );
|
|
||||||
}
|
}
|
||||||
}' | sort
|
}' | sort
|
||||||
}
|
}
|
||||||
@@ -269,172 +346,95 @@ function branchesByDate() {
|
|||||||
|
|
||||||
function changelogs() {
|
function changelogs() {
|
||||||
local author="${1:-}"
|
local author="${1:-}"
|
||||||
local _author
|
local _author=""
|
||||||
if [ -z "$author" ]; then
|
|
||||||
|
if [[ -z "${author}" ]]; then
|
||||||
option_picked "Git changelogs:"
|
option_picked "Git changelogs:"
|
||||||
_author="--author=**"
|
_author="--author=**"
|
||||||
else
|
else
|
||||||
option_picked "Git changelogs for author '$author':"
|
option_picked "Git changelogs for author '${author}':"
|
||||||
_author="--author=$author"
|
_author="--author=${author}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NEXT=$(date +%F)
|
NEXT=$(date +%F)
|
||||||
git log --use-mailmap --no-merges --format="%cd" --date=short "$_author" $_since $_until $_pathspec | sort -u -r | head -n $_limit | while read DATE ; do
|
git log --use-mailmap --no-merges --format="%cd" --date=short "${_author}" $_since $_until $_pathspec | sort -u -r | head -n $_limit | while read DATE ; do
|
||||||
echo
|
echo
|
||||||
echo "[$DATE]"
|
echo "[$DATE]"
|
||||||
GIT_PAGER=cat git log --use-mailmap --no-merges --format=" * %s (%aN)" "$_author" --since=$DATE --until=$NEXT
|
GIT_PAGER=cat git log --use-mailmap --no-merges --format=" * %s (%aN)" "${_author}" --since=$DATE --until=$NEXT
|
||||||
NEXT=$DATE
|
NEXT=$DATE
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check to make sure all utilities required for this script are installed
|
||||||
|
check_utils
|
||||||
|
|
||||||
# Check if we are currently in a git repo.
|
# Check if we are currently in a git repo.
|
||||||
git rev-parse --is-inside-work-tree > /dev/null
|
git rev-parse --is-inside-work-tree > /dev/null
|
||||||
|
|
||||||
if [ $# -eq 1 ]
|
# Parse non-interative commands
|
||||||
then
|
if [[ "$#" -eq 1 ]]; then
|
||||||
case $1 in
|
case "$1" in
|
||||||
"suggestReviewers")
|
-r|--suggest-reviewers) suggestReviewers;;
|
||||||
suggestReviewers
|
-T|--detailed-git-stats) detailedGitStats;;
|
||||||
;;
|
-b|--branch-tree) branchTree;;
|
||||||
"detailedGitStats")
|
-d|--commits-per-day) commitsPerDay;;
|
||||||
detailedGitStats
|
-a|--commits-per-author) commitsPerAuthor;;
|
||||||
;;
|
-S|--my-daily-stats) myDailyStats;;
|
||||||
"branchTree")
|
-C|--contributors) contributors;;
|
||||||
branchTree
|
-D|--branches-by-date) branchesByDate;;
|
||||||
;;
|
-c|--changelogs) changelogs;;
|
||||||
"commitsPerDay")
|
-L|--changelogs-by-author)
|
||||||
commitsPerDay
|
author="${_GIT_AUTHOR:-}"
|
||||||
;;
|
while [[ -z "${author}" ]]; do
|
||||||
"commitsPerAuthor")
|
read -r -p "Which author? " author
|
||||||
commitsPerAuthor
|
done
|
||||||
;;
|
changelogs "${author}";;
|
||||||
"myDailyStats")
|
-w|--commits-by-weekday) commitsByWeekday;;
|
||||||
myDailyStats
|
-o|--commits-by-hour) commitsByHour;;
|
||||||
;;
|
-A|--commits-by-author-by-hour)
|
||||||
"contributors")
|
author="${_GIT_AUTHOR:-}"
|
||||||
contributors
|
while [[ -z "${author}" ]]; do
|
||||||
;;
|
read -r -p "Which author? " author
|
||||||
"branchesByDate")
|
done
|
||||||
branchesByDate
|
commitsByHour "${author}";;
|
||||||
;;
|
-m|--commits-by-month) commitsByMonth;;
|
||||||
"changelogs")
|
-h|-\?|--help) usage;;
|
||||||
changelogs
|
*) echo "Invalid argument"; usage; exit 1;;
|
||||||
;;
|
esac
|
||||||
"changelogsByAuthor")
|
exit 0;
|
||||||
author="${_GIT_AUTHOR:-}"
|
|
||||||
while [ -z "$author" ]; do read -p "Which author? " author; done
|
|
||||||
changelogs "$author"
|
|
||||||
;;
|
|
||||||
"commitsByWeekday")
|
|
||||||
commitsByWeekday
|
|
||||||
;;
|
|
||||||
"commitsByHour")
|
|
||||||
commitsByHour
|
|
||||||
;;
|
|
||||||
"commitsByAuthorByHour")
|
|
||||||
author="${_GIT_AUTHOR:-}"
|
|
||||||
while [ -z "$author" ]; do read -p "Which author? " author; done
|
|
||||||
commitsByHour "$author"
|
|
||||||
;;
|
|
||||||
"commitsByMonth")
|
|
||||||
commitsByMonth
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Invalid argument. Possible arguments: suggestReviewers, detailedGitStats, commitsPerDay, commitsByMonth, commitsByWeekday, commitsByHour, commitsByAuthorByHour, commitsPerAuthor, myDailyStats, contributors, branchTree, branchesByDate, changelogs, changelogsByAuthor"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
exit 0;
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $# -gt 1 ]
|
|
||||||
then
|
|
||||||
echo "Usage: git quick-stats <optional-command-to-execute-directly>";
|
|
||||||
exit 1;
|
|
||||||
fi
|
fi
|
||||||
|
[[ "$#" -gt 1 ]] && { echo "Invalid arguments"; usage; exit 1; }
|
||||||
|
|
||||||
|
# Parse interactive commands
|
||||||
clear
|
clear
|
||||||
show_menu
|
show_menu
|
||||||
|
|
||||||
while [ opt != '' ]
|
while [[ "${opt}" != "" ]]; do
|
||||||
do
|
clear
|
||||||
if [[ $opt = "" ]]; then
|
case "${opt}" in
|
||||||
exit;
|
1) detailedGitStats; show_menu;;
|
||||||
else
|
2) changelogs; show_menu;;
|
||||||
clear
|
3) author=""
|
||||||
case $opt in
|
while [[ -z "${author}" ]]; do
|
||||||
1)
|
read -r -p "Which author? " author
|
||||||
detailedGitStats
|
done
|
||||||
show_menu
|
changelogs "${author}"; show_menu;;
|
||||||
;;
|
4) myDailyStats; show_menu;;
|
||||||
2)
|
5) branchTree; show_menu;;
|
||||||
changelogs
|
6) branchesByDate; show_menu;;
|
||||||
show_menu
|
7) contributors; show_menu;;
|
||||||
;;
|
8) commitsPerAuthor; show_menu;;
|
||||||
3)
|
9) commitsPerDay; show_menu;;
|
||||||
author=''
|
10) commitsByMonth; show_menu;;
|
||||||
while [ -z "$author" ]; do read -p "Which author? " author; done
|
11) commitsByWeekday; show_menu;;
|
||||||
changelogs "$author"
|
12) commitsByHour; show_menu;;
|
||||||
show_menu
|
13) author=""
|
||||||
;;
|
while [[ -z "${author}" ]]; do
|
||||||
4)
|
read -r -p "Which author? " author
|
||||||
myDailyStats
|
done
|
||||||
show_menu
|
commitsByHour "${author}"; show_menu;;
|
||||||
;;
|
14) suggestReviewers; show_menu;;
|
||||||
5)
|
q|"\n") exit;;
|
||||||
branchTree
|
*) clear; option_picked "Pick an option from the menu"; show_menu;;
|
||||||
show_menu
|
|
||||||
;;
|
|
||||||
6)
|
|
||||||
branchesByDate
|
|
||||||
show_menu
|
|
||||||
;;
|
|
||||||
7)
|
|
||||||
contributors
|
|
||||||
show_menu
|
|
||||||
;;
|
|
||||||
8)
|
|
||||||
commitsPerAuthor
|
|
||||||
show_menu
|
|
||||||
;;
|
|
||||||
9)
|
|
||||||
commitsPerDay
|
|
||||||
show_menu
|
|
||||||
;;
|
|
||||||
10)
|
|
||||||
commitsByMonth
|
|
||||||
show_menu
|
|
||||||
;;
|
|
||||||
11)
|
|
||||||
commitsByWeekday
|
|
||||||
show_menu
|
|
||||||
;;
|
|
||||||
12)
|
|
||||||
commitsByHour
|
|
||||||
show_menu
|
|
||||||
;;
|
|
||||||
13)
|
|
||||||
author=''
|
|
||||||
while [ -z "$author" ]; do read -p "Which author? " author; done
|
|
||||||
commitsByHour "$author"
|
|
||||||
show_menu
|
|
||||||
;;
|
|
||||||
14)
|
|
||||||
suggestReviewers
|
|
||||||
show_menu
|
|
||||||
;;
|
|
||||||
q)
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
\n)
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
clear
|
|
||||||
option_picked "Pick an option from the menu"
|
|
||||||
show_menu
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
esac
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
. tests/assert.sh -v
|
. tests/assert.sh -v
|
||||||
|
|
||||||
src="./git-quick-stats"
|
src="./git-quick-stats"
|
||||||
|
#assert "$src fail" "Invalid argument\n\nNAME\n git-quick-stats - Simple and efficient way to access various stats in a git repo\n\nSYNOPSIS\n For non-interactive mode: git-quick-stats [OPTIONS]\n For interactive mode: git-quick-stats\n\nDESCRIPTION\n Any git repository contains tons of information about commits, contributors,\n and files. Extracting this information is not always trivial, mostly because\n of a gadzillion options to a gadzillion git commands.\n\n This program allows you to see detailed information about a git repository.\n\nOPTIONS\n suggestReviewers - see best people to contact to review code\n detailedGitStats - displays a detailed list of git status\n commitsPerDay - displays a list of commits per day\n commitsByMonth - displays a list of commits per month\n commitsByWeekday - displays a list of commits per weekday\n commitsByHour - displays a list of commits per hour\n commitsByAuthorByHour - see a list of commits per hour by author\n commitsPerAuthor - displays a list of commits per author\n myDailyStats - see your current daily stats\n contributors - see a list of all contributors\n branchTree - see an ASCII graph of the git repo\n branchesByDate - show branches by date\n changelogs - see changelogs\n changelogsByAuthor - see changelogs by author\n\nADDITIONAL USAGE\n You can set _GIT_SINCE and _GIT_UNTIL to limit the git time log\n ex: export _GIT_SINCE=2017-20-01\n You can set _GIT_LIMIT for limited output log\n ex: export _GIT_LIMIT=20\n You can exclude a directory from the stats by using pathspec\n ex: export _GIT_PATHSPEC=':!directory'\n \nCONTRIBUTION\n For details regarding contribution, please see the contribution.md document\n\nLICENSE\n This is under the MIT license. See LICENSE in the repo for more info"
|
||||||
assert "$src fail" "Invalid argument. Possible arguments: suggestReviewers, detailedGitStats, commitsPerDay, commitsByMonth, commitsByWeekday, commitsByHour, commitsByAuthorByHour, commitsPerAuthor, myDailyStats, contributors, branchTree, branchesByDate, changelogs, changelogsByAuthor"
|
assert "$src fail" "Invalid argument\n\nNAME\n git-quick-stats - Simple and efficient way to access various stats in a git repo\n\nSYNOPSIS\n For non-interactive mode: git-quick-stats [OPTIONS]\n For interactive mode: git-quick-stats\n\nDESCRIPTION\n Any git repository contains tons of information about commits, contributors,\n and files. Extracting this information is not always trivial, mostly because\n of a gadzillion options to a gadzillion git commands.\n\n This program allows you to see detailed information about a git repository.\n\nOPTIONS\n -r, --suggest-reviewers\n show the best people to contact to review code\n -T, --detailed-git-stats\n give a detailed list of git stats\n -d, --commits-per-day\n displays a list of commits per day\n -m, --commits-by-month\n displays a list of commits per month\n -w, --commits-by-weekday\n displays a list of commits per weekday\n -o, --commits-by-hour\n displays a list of commits per hour\n -A, --commits-by-author-by-hour\n displays a list of commits per hour by author\n -a, --commits-per-author\n displays a list of commits per author\n -S, --my-daily-stats\n see your current daily stats\n -C, --contributors\n see a list of everyone who contributed to the repo\n -b, --branch-tree\n show an ASCII graph of the git repo branch history\n -D, --branches-by-date\n show branches by date\n -c, --changelogs\n see changelogs\n -L, --changelogs-by-author\n see changelogs by author\n -h, -?, --help\n display this help text in the terminal\n\nADDITIONAL USAGE\n You can set _GIT_SINCE and _GIT_UNTIL to limit the git time log\n ex: export _GIT_SINCE=\"2017-20-01\"\n You can set _GIT_LIMIT for limited output log\n ex: export _GIT_LIMIT=20\n You can exclude a directory from the stats by using pathspec\n ex: export _GIT_PATHSPEC=':!directory'"
|
||||||
assert_raises "$src fail" 1
|
assert_raises "$src fail" 1
|
||||||
|
|
||||||
assert_contains "$src suggestReviewers" "Suggested code reviewers (based on git history)" 127
|
assert_contains "$src --suggest-reviewers" "Suggested code reviewers (based on git history)" 127
|
||||||
assert_raises "$src suggestReviewers" 0
|
assert_raises "$src --suggest-reviewers" 0
|
||||||
|
|
||||||
assert_contains "$src detailedGitStats" "Contribution stats" 127
|
assert_contains "$src --detailed-git-stats" "Contribution stats" 127
|
||||||
assert_raises "$src detailedGitStats" 0
|
assert_raises "$src --detailed-git-stats" 0
|
||||||
|
|
||||||
assert_contains "$src commitsPerDay" "Git commits per date" 127
|
assert_contains "$src --commits-per-day" "Git commits per date" 127
|
||||||
assert_raises "$src commitsPerDay" 0
|
assert_raises "$src --commits-per-day" 0
|
||||||
|
|
||||||
assert_end
|
assert_end
|
||||||
|
|||||||
Reference in New Issue
Block a user