mirror of
https://github.com/git-quick-stats/git-quick-stats.git
synced 2025-12-21 12:13:52 +01:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b1e0b2a65 | ||
|
|
43bc82520e | ||
|
|
d33ede9bcc | ||
|
|
7f24d202b9 | ||
|
|
62b128a3ce | ||
|
|
8515fe3a94 | ||
|
|
37bfde67ed | ||
|
|
d886facadf | ||
|
|
aa6619508a | ||
|
|
a813846c9f | ||
|
|
22bf354da4 | ||
|
|
0fea0323a4 | ||
|
|
4fcf8f5fef | ||
|
|
374aa2ef72 | ||
|
|
33dca7f3ed | ||
|
|
2ecb296442 | ||
|
|
428d25d0ef | ||
|
|
c3110e985e | ||
|
|
ebbeb34837 | ||
|
|
6cdca7c7c7 | ||
|
|
71d414eb4a | ||
|
|
d8346210a4 | ||
|
|
b85760e8b9 | ||
|
|
07ad3b57a7 | ||
|
|
dec1c4e103 | ||
|
|
2a0294941f |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -7,4 +7,7 @@
|
||||
.Spotlight*
|
||||
.Trash*
|
||||
**/*~
|
||||
nbproject/*
|
||||
nbproject/*
|
||||
/tests/test-git/.git/
|
||||
#/tests/test-git/*
|
||||
!/tests/test-git/resetgit
|
||||
|
||||
1
Makefile
1
Makefile
@@ -3,6 +3,7 @@ _INSTDIR ?= $(DESTDIR)$(PREFIX)
|
||||
BINDIR ?= $(_INSTDIR)/bin
|
||||
MANDIR ?= $(_INSTDIR)/share/man
|
||||
TASK_DONE = echo -e "\n✓ $@ done\n"
|
||||
SHELL := $(shell which bash)
|
||||
|
||||
.PHONY: test
|
||||
|
||||
|
||||
19
README.md
19
README.md
@@ -1,11 +1,13 @@
|
||||
|
||||
# GIT quick statistics [](#backers) [](#sponsors) [](https://twitter.com/intent/tweet?text=Simple%20and%20efficient%20way%20to%20access%20various%20statistics%20in%20git%20repository&url=https://github.com/arzzen/git-quick-stat&via=arzzen&hashtags=git,stats,tool,statistics,developers) [](https://travis-ci.org/arzzen/git-quick-stats) [](https://formulae.brew.sh/formula/git-quick-stats#default) [](https://repology.org/metapackage/git-quick-stats/packages)
|
||||
# GIT quick statistics [](https://twitter.com/intent/tweet?text=Simple%20and%20efficient%20way%20to%20access%20various%20statistics%20in%20git%20repository&url=https://github.com/arzzen/git-quick-stat&via=arzzen&hashtags=git,stats,tool,statistics,developers)
|
||||
[](#backers) [](#sponsors) [](https://formulae.brew.sh/formula/git-quick-stats#default)
|
||||
|
||||
> `git-quick-stats` is a simple and efficient way to access various statistics in a git repository.
|
||||
>
|
||||
> 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 +55,9 @@
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
@@ -119,10 +121,14 @@ LIST OPTIONS
|
||||
displays a list of commits per author
|
||||
-d, --commits-per-day
|
||||
displays a list of commits per day
|
||||
-Y, --commits-by-year
|
||||
displays a list of commits per year
|
||||
-m, --commits-by-month
|
||||
displays a list of commits per month
|
||||
-w, --commits-by-weekday
|
||||
displays a list of commits per weekday
|
||||
-W, --commits-by-author-by-weekday
|
||||
displays a list of commits per weekday by author
|
||||
-o, --commits-by-hour
|
||||
displays a list of commits per hour
|
||||
-A, --commits-by-author-by-hour
|
||||
@@ -152,7 +158,7 @@ Once set, run `git quick-stats` as normal. Note that this affects all stats that
|
||||
|
||||
### Git log limit
|
||||
|
||||
You can set variable `_GIT_LIMIT` for limited output. It will affect the "changelogs" and "branch tree" options.
|
||||
You can set variable `_GIT_LIMIT` for limited output. It will affect the "changelogs" and "branch tree" options. The default limit is `10`.
|
||||
|
||||
```bash
|
||||
export _GIT_LIMIT=20
|
||||
@@ -205,7 +211,7 @@ You can change to the legacy color scheme by toggling the variable `_MENU_THEME`
|
||||
export _MENU_THEME="legacy"
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
@@ -281,7 +287,6 @@ sort
|
||||
tput
|
||||
tr
|
||||
uniq
|
||||
wc
|
||||
```
|
||||
|
||||
### Dependencies
|
||||
|
||||
244
git-quick-stats
244
git-quick-stats
@@ -11,13 +11,13 @@ set -o nounset
|
||||
set -o errexit
|
||||
|
||||
# Beginning git log date. Respects all git datetime formats
|
||||
# If $_GIT_SINCE is never set, choose epoch time as that is
|
||||
# as far back as git will allow you to go
|
||||
# If $_GIT_SINCE is never set, look at the repository to find the first date.
|
||||
# NOTE: previously this put the date at the fixed GIT epoch (May 2005)
|
||||
_since=${_GIT_SINCE:-}
|
||||
if [[ -n "${_since}" ]]; then
|
||||
_since="--since=$_since"
|
||||
else
|
||||
_since="--since=2005-04-07"
|
||||
_since="--since=$(git log --reverse --format='%ad' | head -n1)"
|
||||
fi
|
||||
|
||||
# End of git log date. Respects all git datetime formats
|
||||
@@ -27,7 +27,7 @@ _until=${_GIT_UNTIL:-}
|
||||
if [[ -n "${_until}" ]]; then
|
||||
_until="--until=$_until"
|
||||
else
|
||||
_until="--until=$(date)"
|
||||
_until="--until=$(date '+%a, %d %b %Y %H:%M:%S %Z')"
|
||||
fi
|
||||
|
||||
# Set files or directories to be excluded in stats
|
||||
@@ -83,7 +83,7 @@ _theme="${_MENU_THEME:=default}"
|
||||
function checkUtils() {
|
||||
readonly MSG="not found. Please make sure this is installed and in PATH."
|
||||
readonly UTILS="awk basename cat column echo git grep head printf seq sort \
|
||||
tput tr uniq wc"
|
||||
tput tr uniq"
|
||||
|
||||
for u in $UTILS
|
||||
do
|
||||
@@ -102,6 +102,23 @@ function optionPicked() {
|
||||
echo -e "${msg}\n"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# DESC: Format date string
|
||||
# ARGS: $* (required): String
|
||||
# OUTS: String
|
||||
################################################################################
|
||||
format_date() {
|
||||
local date="${1}"
|
||||
local outf="${2}"
|
||||
local datef="${3:-"%b %d %H:%M:%S %Y %Z"}" # Tue Oct 24 13:34:22 2023 +0300
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
local resp="$(date -d "${date}" "+${outf}")"
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
local resp="$(date -j -f "${datef}" "${date}" "+${outf}")"
|
||||
fi
|
||||
printf "%s" "${resp}"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# DESC: Help information printed to stdout during non-interactive mode
|
||||
# ARGS: None
|
||||
@@ -154,8 +171,12 @@ LIST OPTIONS
|
||||
displays a list of commits per day
|
||||
-m, --commits-by-month
|
||||
displays a list of commits per month
|
||||
-Y, --commits-by-year
|
||||
displays a list of commits per year
|
||||
-w, --commits-by-weekday
|
||||
displays a list of commits per weekday
|
||||
-W, --commits-by-author-by-weekday
|
||||
displays a list of commits per weekday by author
|
||||
-o, --commits-by-hour
|
||||
displays a list of commits per hour
|
||||
-A, --commits-by-author-by-hour
|
||||
@@ -239,13 +260,15 @@ function showMenu() {
|
||||
printf %b "${NUMS} 11)${TEXT} Git commits per author\\n"
|
||||
printf %b "${NUMS} 12)${TEXT} Git commits per date\\n"
|
||||
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 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 "${NUMS} 14)${TEXT} Git commits per year\\n"
|
||||
printf %b "${NUMS} 15)${TEXT} Git commits per weekday\\n"
|
||||
printf %b "${NUMS} 16)${TEXT} Git commits per weekday by author\\n"
|
||||
printf %b "${NUMS} 17)${TEXT} Git commits per hour\\n"
|
||||
printf %b "${NUMS} 18)${TEXT} Git commits per hour by author\\n"
|
||||
printf %b "${NUMS} 19)${TEXT} Git commits per timezone\\n"
|
||||
printf %b "${NUMS} 20)${TEXT} Git commits per timezone by author\\n"
|
||||
printf %b "\\n${TITLES} Suggest:\\n"
|
||||
printf %b "${NUMS} 19)${TEXT} Code reviewers (based on git history)\\n"
|
||||
printf %b "${NUMS} 21)${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
|
||||
@@ -388,11 +411,12 @@ function changelogs() {
|
||||
--date=short "${_author}" "$_since" "$_until" $_log_options $_pathspec \
|
||||
| sort -u -r | head -n $_limit \
|
||||
| while read DATE; do
|
||||
echo -e "\n[$DATE]"
|
||||
day=$(format_date "$DATE" "%A" "%Y-%m-%d")
|
||||
echo -e "\n[$DATE - $day]"
|
||||
GIT_PAGER=cat git -c log.showSignature=false log \
|
||||
--use-mailmap $_merges \
|
||||
--format=" * %s (%aN)" "${_author}" \
|
||||
--since=$DATE --until=$next
|
||||
--since==$(date -d "$DATE - 1 day" +"%Y-%m-%d") --until=$next
|
||||
next=$DATE
|
||||
done
|
||||
}
|
||||
@@ -416,7 +440,7 @@ function myDailyStats() {
|
||||
--author="$(git config user.name)" $_merges \
|
||||
--since=$(date "+%Y-%m-%dT00:00:00") \
|
||||
--until=$(date "+%Y-%m-%dT23:59:59") --reverse $_log_options \
|
||||
| grep -E "commit [a-f0-9]{40}" | wc -l) "commits"
|
||||
| grep -cE "commit [a-f0-9]{40}") "commits"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -516,6 +540,67 @@ function csvOutput() {
|
||||
}'
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# DESC: Transforms special multiline string sequence to a JSON string property.
|
||||
# {propTag}{optional white space indentation}{property}
|
||||
# {line1}
|
||||
# {line2}
|
||||
# ...
|
||||
# {propTag}, (the final comma is optional)
|
||||
# Generates: "{property}": "{line1}\n{line2}\n...",
|
||||
# The final comma is added if present after the ending tag.
|
||||
# Caveat: the content should not contain {propTag} at the
|
||||
# beginning of a line.
|
||||
# ARGS: $propTag (optional) : tag at the beginning of the line to mark the
|
||||
# beginning and the end of a special sequence. It must not contain
|
||||
# regular expression special characters, i.e. use [a-zA-Z0-9_]+.
|
||||
# This tag should be sufficiently random to avoid collision with
|
||||
# the actual content. Defaults to __JSONPROP__.
|
||||
# OUTS: content with JSON string properties
|
||||
################################################################################
|
||||
function toJsonProp() {
|
||||
local propTag="${1:-__JSONPROP__}"
|
||||
sed -n -E '
|
||||
# transforms the special sequence.
|
||||
/^'"$propTag"'[^\r]/ {
|
||||
# remove the special prefix, keep the property name followed by :
|
||||
s/^'"$propTag"'([^\r]+)\r?$/\1:/g;
|
||||
# hold in buffer, get the next line.
|
||||
h;n
|
||||
# loop
|
||||
b eos
|
||||
:eos {
|
||||
# add in hold buffer and loop while the string is not finished.
|
||||
/^'"$propTag"',?\r?$/ ! { H; n; b eos; }
|
||||
# end of the string, flip buffer to current pattern.
|
||||
# keeps the comma if any, or a space as an empty placeholder.
|
||||
/,\r?$/ ! { x; s/\r?$/ / }
|
||||
/,\r?$/ { x; s/\r?$/,/ }
|
||||
}
|
||||
# replace special JSON string chars.
|
||||
s/["\\]/\\&/g;
|
||||
# replace control chars, carriage returns, line feeds, tabulations, etc.
|
||||
s/\x00/\\u0000/g; s/\x01/\\u0001/g; s/\x02/\\u0002/g; s/\x03/\\u0003/g;
|
||||
s/\x04/\\u0004/g; s/\x05/\\u0005/g; s/\x06/\\u0006/g; s/\x07/\\u0007/g;
|
||||
s/\x08/\\b/g; s/\x09/\\t/g; s/\x0a/\\n/g; s/\x0b/\\u000b/g;
|
||||
s/\x0c/\\f/g; s/\x0d/\\r/g; s/\x0e/\\u000e/g; s/\x0f/\\u000f/g;
|
||||
s/\x10/\\u0010/g; s/\x11/\\u0011/g; s/\x12/\\u0012/g; s/\x13/\\u0013/g;
|
||||
s/\x14/\\u0014/g; s/\x15/\\u0015/g; s/\x16/\\u0016/g; s/\x17/\\u0017/g;
|
||||
s/\x18/\\u0018/g; s/\x19/\\u0019/g; s/\x1a/\\u001a/g; s/\x1b/\\u001b/g;
|
||||
s/\x1c/\\u001c/g; s/\x1d/\\u001d/g; s/\x1e/\\u001e/g; s/\x1f/\\u001f/g;
|
||||
s/\x7f/\\u007f/g;
|
||||
|
||||
# format the JSON property name, optionally indented, open quote for value.
|
||||
s/^(\s*)([^:]+):\\n/\1"\2": "/g;
|
||||
# handle the final comma if present, and close the quote for value.
|
||||
/,$/ { s/,$/",/g; }
|
||||
# otherwise remove final space placeholder and close the quote for value.
|
||||
/,$/ ! { s/ $/"/g; }
|
||||
}
|
||||
# print lines.
|
||||
p'
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# DESC: Saves the git log output in a JSON format
|
||||
# ARGS: $json_path (required): Path to where the file is saved
|
||||
@@ -523,10 +608,20 @@ function csvOutput() {
|
||||
################################################################################
|
||||
function jsonOutput() {
|
||||
optionPicked "Output log saved to file at: ${json_path}/output.json"
|
||||
# TODO: Can we shorten this pretty format line? Quick experiment shows that
|
||||
# it does not properly respect \ and interprets them literally.
|
||||
local propTag="__JSONPROP${RANDOM}__"
|
||||
git -c log.showSignature=false log --use-mailmap $_merges "$_since" "$_until" $_log_options \
|
||||
--pretty=format:'{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n "subject": "%s",%n "sanitized_subject_line": "%f",%n "body": "%b",%n "commit_notes": "%N",%n "author": {%n "name": "%aN",%n "email": "%aE",%n "date": "%aD"%n },%n "commiter": {%n "name": "%cN",%n "email": "%cE",%n "date": "%cD"%n }%n},' \
|
||||
--pretty=format:'{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n'\
|
||||
' "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n'\
|
||||
"$propTag"' subject%n%s%n'"$propTag"',%n "sanitized_subject_line": "%f",%n'\
|
||||
"$propTag"' body%n%b%n'"$propTag"',%n'\
|
||||
"$propTag"' commit_notes%n%N%n'"$propTag"',%n "author": {%n'\
|
||||
"$propTag"' name%n%aN%n'"$propTag"',%n'\
|
||||
"$propTag"' email%n%aE%n'"$propTag"',%n'\
|
||||
' "date": "%aD"%n },%n "commiter": {%n'\
|
||||
"$propTag"' name%n%cN%n'"$propTag"',%n'\
|
||||
"$propTag"' email%n%cE%n'"$propTag"',%n'\
|
||||
' "date": "%cD"%n }%n},' \
|
||||
| toJsonProp "$propTag" \
|
||||
| sed "$ s/,$//" \
|
||||
| sed ':a;N;$!ba;s/\r\n\([^{]\)/\\n\1/g' \
|
||||
| awk 'BEGIN { print("[") } { print($0) } END { print("]") }' \
|
||||
@@ -618,6 +713,56 @@ function commitsPerDay() {
|
||||
--date=short --format='%ad' $_log_options $_pathspec | sort | uniq -c
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# DESC: Displays a horizontal bar graph based on total commits per year
|
||||
# ARGS: None
|
||||
# OUTS: None
|
||||
################################################################################
|
||||
function commitsByYear() {
|
||||
optionPicked "Git commits by year:"
|
||||
local year startYear endYear __since __until
|
||||
startYear=$(echo "$_since" | sed -E 's/^.* ([0-9]{4})( .*)?$/\1/')
|
||||
endYear=$(echo "$_until" | sed -E 's/^.* ([0-9]{4})( .*)?$/\1/')
|
||||
|
||||
echo -e "\tyear\tsum"
|
||||
for year in $(seq "$startYear" "$endYear")
|
||||
do
|
||||
if [ "$year" = "$startYear" ]
|
||||
then
|
||||
__since=$_since
|
||||
__until="--until=$year-12-31"
|
||||
elif [ "$year" = "$endYear" ]
|
||||
then
|
||||
__since="--since=$year-01-01"
|
||||
__until=$_until
|
||||
else
|
||||
__since="--since=$year-01-01"
|
||||
__until="--until=$year-12-31"
|
||||
fi
|
||||
|
||||
echo -en "\t$year\t"
|
||||
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
|
||||
"$__since" "$__until" $_log_options | grep -cE \
|
||||
" \w\w\w [0-9]{1,2} [0-9][0-9]:[0-9][0-9]:[0-9][0-9] $year " \
|
||||
|| continue
|
||||
done | awk '{
|
||||
count[$1] = $2
|
||||
total += $2
|
||||
}
|
||||
END{
|
||||
for (year in count) {
|
||||
s="|";
|
||||
if (total > 0) {
|
||||
percent = ((count[year] / total) * 100) / 1.25;
|
||||
for (i = 1; i <= percent; ++i) {
|
||||
s=s"█"
|
||||
}
|
||||
printf( "\t%s\t%-0s\t%s\n", year, count[year], s );
|
||||
}
|
||||
}
|
||||
}' | sort
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# DESC: Displays a horizontal bar graph based on total commits per month
|
||||
# ARGS: None
|
||||
@@ -626,14 +771,13 @@ function commitsPerDay() {
|
||||
function commitsByMonth() {
|
||||
optionPicked "Git commits by month:"
|
||||
echo -e "\tmonth\tsum"
|
||||
local startYear=$(echo "$_since" | grep -Eo "[0-9]{4}")
|
||||
local endYear=$(echo "$_until" | grep -Eo "[0-9]{4}")
|
||||
local i
|
||||
for i in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
|
||||
do
|
||||
echo -en "\t$i\t"
|
||||
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
|
||||
"$_since" "$_until" $_log_options | grep -E "($startYear|$endYear)" \
|
||||
| grep " $i " | wc -l
|
||||
"$_since" "$_until" $_log_options |
|
||||
grep -cE " \w\w\w $i [0-9]{1,2} " || continue
|
||||
done | awk '{
|
||||
count[$1] = $2
|
||||
total += $2
|
||||
@@ -658,17 +802,25 @@ function commitsByMonth() {
|
||||
# OUTS: None
|
||||
################################################################################
|
||||
function commitsByWeekday() {
|
||||
optionPicked "Git commits by weekday:"
|
||||
local author="${1:-}"
|
||||
local _author=""
|
||||
|
||||
if [[ -z "${author}" ]]; then
|
||||
optionPicked "Git commits by weekday:"
|
||||
_author="--author=**"
|
||||
else
|
||||
optionPicked "Git commits by weekday for author '${author}':"
|
||||
_author="--author=${author}"
|
||||
fi
|
||||
|
||||
echo -e "\tday\tsum"
|
||||
local startYear=$(echo "$_since" | grep -Eo "[0-9]{4}")
|
||||
local endYear=$(echo "$_until" | grep -Eo "[0-9]{4}")
|
||||
local counter=1
|
||||
local i counter=1
|
||||
for i in Mon Tue Wed Thu Fri Sat Sun
|
||||
do
|
||||
echo -en "\t$counter\t$i\t"
|
||||
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
|
||||
"$_since" "$_until" $_log_options | grep -E "($startYear|$endYear)" \
|
||||
| grep "$i " | wc -l
|
||||
"${_author}" "$_since" "$_until" $_log_options |
|
||||
grep -cE "^ * $i \w\w\w [0-9]{1,2} " || continue
|
||||
counter=$((counter+1))
|
||||
done | awk '{
|
||||
}
|
||||
@@ -710,14 +862,13 @@ function commitsByHour() {
|
||||
fi
|
||||
echo -e "\thour\tsum"
|
||||
|
||||
local startYear=$(echo "$_since" | grep -Eo "[0-9]{4}")
|
||||
local endYear=$(echo "$_until" | grep -Eo "[0-9]{4}")
|
||||
local i
|
||||
for i in $(seq -w 0 23)
|
||||
do
|
||||
echo -ne "\t$i\t"
|
||||
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
|
||||
"${_author}" "$_since" "$_until" $_log_options \
|
||||
| grep -E "($startYear|$endYear)" | grep ' '$i: | wc -l
|
||||
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
|
||||
"${_author}" "$_since" "$_until" $_log_options |
|
||||
grep -cE '[0-9] '$i':[0-9]' || continue
|
||||
done | awk '{
|
||||
count[$1] = $2
|
||||
total += $2
|
||||
@@ -754,9 +905,9 @@ function commitsByTimezone() {
|
||||
fi
|
||||
|
||||
echo -e "Commits\tTimeZone"
|
||||
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
|
||||
git -c log.showSignature=false log $_merges --format='%ad %s' \
|
||||
"${_author}" "$_since" "$_until" --date=iso $_log_options $_pathspec \
|
||||
| cut -d " " -f 12 | grep -v -e '^[[:space:]]*$' | sort | uniq -c
|
||||
| cut -d " " -f 3 | grep -v -e '^[[:space:]]*$' | sort -n | uniq -c
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -838,8 +989,15 @@ if [[ "$#" -eq 1 ]]; then
|
||||
-C|--contributors) contributors;;
|
||||
-a|--commits-per-author) commitsPerAuthor;;
|
||||
-d|--commits-per-day) commitsPerDay;;
|
||||
-Y|--commits-by-year ) commitsByYear;;
|
||||
-m|--commits-by-month) commitsByMonth;;
|
||||
-w|--commits-by-weekday) commitsByWeekday;;
|
||||
-W|--commits-by-author-by-weekday)
|
||||
author="${_GIT_AUTHOR:-}"
|
||||
while [[ -z "${author}" ]]; do
|
||||
read -r -p "Which author? " author
|
||||
done
|
||||
commitsByWeekday "${author}";;
|
||||
-o|--commits-by-hour) commitsByHour;;
|
||||
-A|--commits-by-author-by-hour)
|
||||
author="${_GIT_AUTHOR:-}"
|
||||
@@ -848,7 +1006,7 @@ if [[ "$#" -eq 1 ]]; then
|
||||
done
|
||||
commitsByHour "${author}";;
|
||||
-z|--commits-by-timezone) commitsByTimezone;;
|
||||
-Z|--commits-by-author-by-timezone)
|
||||
-Z|--commits-by-author-by-timezone)
|
||||
author="${_GIT_AUTHOR:-}"
|
||||
while [[ -z "${author}" ]]; do
|
||||
read -r -p "Which author? " author
|
||||
@@ -911,20 +1069,26 @@ while [[ "${opt}" != "" ]]; do
|
||||
11) commitsPerAuthor; showMenu;;
|
||||
12) commitsPerDay; showMenu;;
|
||||
13) commitsByMonth; showMenu;;
|
||||
14) commitsByWeekday; showMenu;;
|
||||
15) commitsByHour; showMenu;;
|
||||
14) commitsByYear; showMenu;;
|
||||
15) commitsByWeekday; showMenu;;
|
||||
16) author=""
|
||||
while [[ -z "${author}" ]]; do
|
||||
read -r -p "Which author? " author
|
||||
done
|
||||
commitsByHour "${author}"; showMenu;;
|
||||
17) commitsByTimezone; showMenu;;
|
||||
commitsByWeekday "${author}"; showMenu;;
|
||||
17) commitsByHour; showMenu;;
|
||||
18) author=""
|
||||
while [[ -z "${author}" ]]; do
|
||||
read -r -p "Which author? " author
|
||||
done
|
||||
commitsByHour "${author}"; showMenu;;
|
||||
19) commitsByTimezone; showMenu;;
|
||||
20) author=""
|
||||
while [[ -z "${author}" ]]; do
|
||||
read -r -p "Which author? " author
|
||||
done
|
||||
commitsByTimezone "${author}"; showMenu;;
|
||||
19) suggestReviewers; showMenu;;
|
||||
21) suggestReviewers; showMenu;;
|
||||
q|"\n") exit;;
|
||||
*) clear; optionPicked "Pick an option from the menu"; showMenu;;
|
||||
esac
|
||||
|
||||
@@ -85,11 +85,21 @@ displays a list of commits per day
|
||||
displays a list of commits per month
|
||||
.HP
|
||||
.PP
|
||||
\fB\-Y\fR, \fB\-\-commits\-by\-year\fR
|
||||
.IP
|
||||
displays a list of commits per year
|
||||
.HP
|
||||
.PP
|
||||
\fB\-w\fR, \fB\-\-commits\-by\-weekday\fR
|
||||
.IP
|
||||
displays a list of commits per weekday
|
||||
.HP
|
||||
.PP
|
||||
\fB\-W\fR, \fB\-\-commits\-by\author\-by\-weekday\fR
|
||||
.IP
|
||||
displays a list of commits per weekday by author
|
||||
.HP
|
||||
.PP
|
||||
\fB\-o\fR, \fB\-\-commits\-by\-hour\fR
|
||||
.IP
|
||||
displays a list of commits per hour
|
||||
|
||||
@@ -79,7 +79,7 @@ assert_end() {
|
||||
tests_endtime="$(date +%s%N)"
|
||||
# required visible decimal place for seconds (leading zeros if needed)
|
||||
local tests_time="$( \
|
||||
printf "%010d" "$(( ${tests_endtime/%N/000000000}
|
||||
printf "%010d" "$(( ${tests_endtime/%N/000000000}
|
||||
- ${tests_starttime/%N/000000000} ))")" # in ns
|
||||
tests="$tests_ran ${*:+$* }tests"
|
||||
[[ -n "$DISCOVERONLY" ]] && echo "collected $tests." && _assert_reset && return
|
||||
@@ -105,7 +105,7 @@ assert_end() {
|
||||
assert() {
|
||||
# assert <command> <expected stdout> [stdin]
|
||||
(( tests_ran++ )) || :
|
||||
[[ -z "$DISCOVERONLY" ]] || return
|
||||
[[ -z "$DISCOVERONLY" ]] || return 0
|
||||
expected=$(echo -ne "${2:-}")
|
||||
result="$(eval 2>/dev/null $1 <<< ${3:-})" || true
|
||||
if [[ "$result" == "$expected" ]]; then
|
||||
@@ -115,13 +115,13 @@ assert() {
|
||||
result="$(sed -e :a -e '$!N;s/\n/\\n/;ta' <<< "$result")"
|
||||
[[ -z "$result" ]] && result="nothing" || result="\"$result\""
|
||||
[[ -z "$2" ]] && expected="nothing" || expected="\"$2\""
|
||||
_assert_fail "expected $expected${_indent}got $result" "$1" "$3"
|
||||
_assert_fail "expected $expected${_indent}got $result" "$1" "${3:-}"
|
||||
}
|
||||
|
||||
assert_raises() {
|
||||
# assert_raises <command> <expected code> [stdin]
|
||||
(( tests_ran++ )) || :
|
||||
[[ -z "$DISCOVERONLY" ]] || return
|
||||
[[ -z "$DISCOVERONLY" ]] || return 0
|
||||
status=0
|
||||
(eval $1 <<< ${3:-}) > /dev/null 2>&1 || status=$?
|
||||
expected=${2:-0}
|
||||
@@ -129,7 +129,12 @@ assert_raises() {
|
||||
[[ -z "$DEBUG" ]] || echo -n .
|
||||
return
|
||||
fi
|
||||
_assert_fail "program terminated with code $status instead of $expected" "$1" "$3"
|
||||
_assert_fail "program terminated with code $status instead of $expected" "$1" "${3:-}"
|
||||
}
|
||||
|
||||
assert_success() {
|
||||
# assert_success <command>
|
||||
assert_raises "$1" 0
|
||||
}
|
||||
|
||||
# _assert_with_grep <grep modifiers> <command> <expected output...>
|
||||
|
||||
@@ -48,8 +48,12 @@ LIST OPTIONS
|
||||
displays a list of commits per day
|
||||
-m, --commits-by-month
|
||||
displays a list of commits per month
|
||||
-Y, --commits-by-year
|
||||
displays a list of commits per year
|
||||
-w, --commits-by-weekday
|
||||
displays a list of commits per weekday
|
||||
-W, --commits-by-author-by-weekday
|
||||
displays a list of commits per weekday by author
|
||||
-o, --commits-by-hour
|
||||
displays a list of commits per hour
|
||||
-A, --commits-by-author-by-hour
|
||||
@@ -86,12 +90,19 @@ ADDITIONAL USAGE
|
||||
assert_raises "$src fail" 1
|
||||
|
||||
assert_contains "$src --suggest-reviewers" "Suggested code reviewers (based on git history)"
|
||||
assert_raises "$src --suggest-reviewers" 0
|
||||
assert_success "$src --suggest-reviewers"
|
||||
|
||||
assert_contains "$src --detailed-git-stats" "Contribution stats"
|
||||
assert_raises "$src --detailed-git-stats" 0
|
||||
assert_success "$src --detailed-git-stats"
|
||||
|
||||
assert_contains "$src --commits-per-day" "Git commits per date"
|
||||
assert_raises "$src --commits-per-day" 0
|
||||
assert_success "$src --commits-per-day"
|
||||
|
||||
assert_startswith "$src --commits-by-year" "Git commits by year"
|
||||
assert_success "$src --commits-by-year"
|
||||
|
||||
export LC_TIME=POSIX
|
||||
assert_startswith "$src --commits-by-year" "Git commits by year"
|
||||
assert_success "$src --commits-by-year"
|
||||
|
||||
assert_end
|
||||
|
||||
17
tests/test-git/resetgit
Executable file
17
tests/test-git/resetgit
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
# Initialises a new local Git repo for test purpose.
|
||||
if test -d ../test-git/.git; then rm -Rf ../test-git/.git; fi
|
||||
#mkdir test-git
|
||||
cd ../test-git
|
||||
git init
|
||||
git config user.name "$(printf %s 'Test Git,\nfor test purpose')"
|
||||
git config user.email "TestGit\o/@example.org"
|
||||
|
||||
#printf '\n[user]\nname = test-git\nemail = test-git@example.org\n'> .git/config
|
||||
printf 'test-git\n========\n' > README.md
|
||||
git add README.md
|
||||
git commit -m 'added readme (o\w/o)' -m 'in markdown, no \r\n, only \n' -m 'a very "simple" readme'
|
||||
testChars="$(printf 'tab [%b] form feed [%b] line feed [%b] carriage return [%b]' '\x09' '\x0C' '\x0A' '\x0D')"
|
||||
#printf '# testChars [%s]\n' "$testChars">&2
|
||||
git notes add -m 'Some notes' -m 'out of ascii: été au cœur' -m "$testChars"
|
||||
git log
|
||||
Reference in New Issue
Block a user