mirror of
https://github.com/git-quick-stats/git-quick-stats.git
synced 2025-12-21 12:13:52 +01:00
Compare commits
22 Commits
2.1.3
...
fix/issue-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f0befcd07 | ||
|
|
292876846d | ||
|
|
e70c288225 | ||
|
|
4d2621b084 | ||
|
|
2318d42765 | ||
|
|
ef74d79102 | ||
|
|
82f8690285 | ||
|
|
0f641ea0e6 | ||
|
|
6c7bd4fddf | ||
|
|
9f9617b88b | ||
|
|
8cea653d6c | ||
|
|
efa004122e | ||
|
|
0534327006 | ||
|
|
a113dc306f | ||
|
|
0fc2fe956b | ||
|
|
1efe3133dc | ||
|
|
3fd0ee2453 | ||
|
|
a4f19c9e54 | ||
|
|
cd38c40fe8 | ||
|
|
3283122a38 | ||
|
|
920b95c042 | ||
|
|
810ffcff54 |
1
.github/FUNDING.yml
vendored
1
.github/FUNDING.yml
vendored
@@ -2,4 +2,5 @@
|
||||
|
||||
github: [arzzen]
|
||||
open_collective: git-quick-stats
|
||||
ko_fi: lukasmestan
|
||||
custom: ['https://lukasmestan.com/thanks/']
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Lukáš Mešťan
|
||||
Copyright (c) 2021 Lukáš Mešťan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
15
README.md
15
README.md
@@ -1,5 +1,5 @@
|
||||
|
||||
# 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) [](http://braumeister.org/formula/git-quick-stats) [](https://repology.org/metapackage/git-quick-stats/packages)
|
||||
# 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-stats` is a simple and efficient way to access various statistics in a git repository.
|
||||
>
|
||||
@@ -190,6 +190,14 @@ export _MENU_THEME=legacy
|
||||
|
||||
## Installation
|
||||
|
||||
### Debian and Ubuntu
|
||||
|
||||
If you are on at least Debian Bullseye or Ubuntu Focal you can use apt for installation:
|
||||
|
||||
```bash
|
||||
apt install git-quick-stats
|
||||
```
|
||||
|
||||
### UNIX and Linux
|
||||
|
||||
```bash
|
||||
@@ -249,6 +257,11 @@ You can use the Docker image provided:
|
||||
|
||||
*A:* You can run the dos2unix app in cygwin as follows: `/bin/dos2unix.exe /usr/local/bin/git-quick-stats`. This will convert the script from the CR-LF convention that Microsoft uses to the LF convention that UNIX, OS X, and Linux use. You should then should be able to run it as normal.
|
||||
|
||||
*Q:* How they could be used in a project with many git projects and statistics would show a summary of all git projects?
|
||||
|
||||
*A:* If you want to include submodule logs, you can try using the following: `export _GIT_LOG_OPTIONS="-p --submodule=log"`
|
||||
(more info about [git log --submodule](https://git-scm.com/docs/git-log#Documentation/git-log.txt---submoduleltformatgt))
|
||||
|
||||
## Contribution
|
||||
|
||||
Want to contribute? Great! First, read this page.
|
||||
|
||||
134
git-quick-stats
134
git-quick-stats
@@ -14,7 +14,7 @@ _since=${_GIT_SINCE:-}
|
||||
if [[ -n "${_since}" ]]; then
|
||||
_since="--since=$_since"
|
||||
else
|
||||
_since="--since=1970-01-01"
|
||||
_since="--since=2005-04-07"
|
||||
fi
|
||||
|
||||
# End of git log date. Respects all git datetime formats
|
||||
@@ -74,14 +74,14 @@ _theme="${_MENU_THEME:=default}"
|
||||
# ARGS: None
|
||||
# OUTS: None
|
||||
################################################################################
|
||||
function checkUtils() {
|
||||
local -r msg="not found. Please make sure this is installed and in PATH."
|
||||
declare -ar utils=("awk" "basename" "cat" "column" "echo" "git" "grep" "head"
|
||||
"seq" "sort" "tput" "tr" "uniq" "wc")
|
||||
checkUtils() {
|
||||
readonly MSG="not found. Please make sure this is installed and in PATH."
|
||||
readonly UTILS="awk basename cat column echo git grep head seq sort tput \
|
||||
tr uniq wc"
|
||||
|
||||
for u in "${utils[@]}"
|
||||
for u in $UTILS
|
||||
do
|
||||
command -v "$u" >/dev/null 2>&1 || { echo >&2 "$u ${msg}"; exit 1; }
|
||||
command -v "$u" >/dev/null 2>&1 || { echo >&2 "$u ${MSG}"; exit 1; }
|
||||
done
|
||||
}
|
||||
|
||||
@@ -90,16 +90,16 @@ function checkUtils() {
|
||||
# ARGS: None
|
||||
# OUTS: None
|
||||
################################################################################
|
||||
function usage() {
|
||||
local -r program=$(basename "$0")
|
||||
usage() {
|
||||
readonly PROGRAM=$(basename "$0")
|
||||
|
||||
echo "
|
||||
NAME
|
||||
${program} - Simple and efficient way to access various stats in a git repo
|
||||
${PROGRAM} - Simple and efficient way to access various stats in a git repo
|
||||
|
||||
SYNOPSIS
|
||||
For non-interactive mode: ${program} [OPTIONS]
|
||||
For interactive mode: ${program}
|
||||
For non-interactive mode: ${PROGRAM} [OPTIONS]
|
||||
For interactive mode: ${PROGRAM}
|
||||
|
||||
DESCRIPTION
|
||||
Any git repository contains tons of information about commits, contributors,
|
||||
@@ -166,55 +166,55 @@ ADDITIONAL USAGE
|
||||
# ARGS: None
|
||||
# OUTS: $opt: Option selected by the user based on menu choice
|
||||
################################################################################
|
||||
function showMenu() {
|
||||
local -r normal=$(tput sgr0)
|
||||
local -r cyan=$(tput setaf 6)
|
||||
local -r bold=$(tput bold)
|
||||
local -r red=$(tput setaf 1)
|
||||
local -r yellow=$(tput setaf 3)
|
||||
local -r white=$(tput setaf 7)
|
||||
local titles=""
|
||||
local text=""
|
||||
local nums=""
|
||||
local help_txt=""
|
||||
local exit_txt=""
|
||||
showMenu() {
|
||||
NORMAL=$(tput sgr0)
|
||||
CYAN=$(tput setaf 6)
|
||||
BOLD=$(tput bold)
|
||||
RED=$(tput setaf 1)
|
||||
YELLOW=$(tput setaf 3)
|
||||
WHITE=$(tput setaf 7)
|
||||
TITLES=""
|
||||
TEXT=""
|
||||
NUMS=""
|
||||
HELP_TXT=""
|
||||
EXIT_TXT=""
|
||||
|
||||
# Adjustable color menu option
|
||||
if [[ "${_theme}" == "legacy" ]]; then
|
||||
titles="${bold}${red}" && readonly titles
|
||||
text="${normal}${cyan}" && readonly text
|
||||
nums="${bold}${yellow}" && readonly nums
|
||||
help_txt="${normal}${yellow}" && readonly help_txt
|
||||
exit_txt="${bold}${red}" && readonly exit_txt
|
||||
TITLES="${BOLD}${RED}"
|
||||
TEXT="${NORMAL}${CYAN}"
|
||||
NUMS="${BOLD}${YELLOW}"
|
||||
HELP_TXT="${NORMAL}${YELLOW}"
|
||||
EXIT_TXT="${BOLD}${RED}"
|
||||
else
|
||||
titles="${bold}${cyan}" && readonly titles
|
||||
text="${normal}${white}" && readonly text
|
||||
nums="${normal}${bold}${white}" && readonly nums
|
||||
help_txt="${normal}${cyan}" && readonly help_txt
|
||||
exit_txt="${bold}${cyan}" && readonly exit_txt
|
||||
TITLES="${BOLD}${CYAN}"
|
||||
TEXT="${NORMAL}${WHITE}"
|
||||
NUMS="${NORMAL}${BOLD}${WHITE}"
|
||||
HELP_TXT="${NORMAL}${CYAN}"
|
||||
EXIT_TXT="${BOLD}${CYAN}"
|
||||
fi
|
||||
|
||||
echo -e "\n${titles} Generate:${normal}"
|
||||
echo -e "${nums} 1)${text} Contribution stats (by author)"
|
||||
echo -e "${nums} 2)${text} Contribution stats (by author) on a specific branch"
|
||||
echo -e "${nums} 3)${text} Git changelogs (last $_limit days)"
|
||||
echo -e "${nums} 4)${text} Git changelogs by author"
|
||||
echo -e "${nums} 5)${text} My daily status"
|
||||
echo -e "${nums} 6)${text} Save git log output in JSON format"
|
||||
echo -e "\n${titles} List:"
|
||||
echo -e "${nums} 7)${text} Branch tree view (last $_limit)"
|
||||
echo -e "${nums} 8)${text} All branches (sorted by most recent commit)"
|
||||
echo -e "${nums} 9)${text} All contributors (sorted by name)"
|
||||
echo -e "${nums} 10)${text} Git commits per author"
|
||||
echo -e "${nums} 11)${text} Git commits per date"
|
||||
echo -e "${nums} 12)${text} Git commits per month"
|
||||
echo -e "${nums} 13)${text} Git commits per weekday"
|
||||
echo -e "${nums} 14)${text} Git commits per hour"
|
||||
echo -e "${nums} 15)${text} Git commits by author per hour"
|
||||
echo -e "\n${titles} Suggest:"
|
||||
echo -e "${nums} 16)${text} Code reviewers (based on git history)"
|
||||
echo -e "\n${help_txt}Please enter a menu option or ${exit_txt}press Enter to exit."
|
||||
echo -n "${text}> ${normal}"
|
||||
printf %b "\\n${TITLES} Generate:${NORMAL}\\n"
|
||||
printf %b "${NUMS} 1)${TEXT} Contribution stats (by author)\\n"
|
||||
printf %b "${NUMS} 2)${TEXT} Contribution stats (by author) on a specific branch\\n"
|
||||
printf %b "${NUMS} 3)${TEXT} Git changelogs (last $_limit days)\\n"
|
||||
printf %b "${NUMS} 4)${TEXT} Git changelogs by author\\n"
|
||||
printf %b "${NUMS} 5)${TEXT} My daily status\\n"
|
||||
printf %b "${NUMS} 6)${TEXT} Save git log output in JSON format\\n"
|
||||
printf %b "\\n${TITLES} List:\\n"
|
||||
printf %b "${NUMS} 7)${TEXT} Branch tree view (last $_limit)\\n"
|
||||
printf %b "${NUMS} 8)${TEXT} All branches (sorted by most recent commit)\\n"
|
||||
printf %b "${NUMS} 9)${TEXT} All contributors (sorted by name)\\n"
|
||||
printf %b "${NUMS} 10)${TEXT} Git commits per author\\n"
|
||||
printf %b "${NUMS} 11)${TEXT} Git commits per date\\n"
|
||||
printf %b "${NUMS} 12)${TEXT} Git commits per month\\n"
|
||||
printf %b "${NUMS} 13)${TEXT} Git commits per weekday\\n"
|
||||
printf %b "${NUMS} 14)${TEXT} Git commits per hour\\n"
|
||||
printf %b "${NUMS} 15)${TEXT} Git commits by author per hour\\n"
|
||||
printf %b "\\n${TITLES} Suggest:\\n"
|
||||
printf %b "${NUMS} 16)${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
|
||||
}
|
||||
|
||||
@@ -224,12 +224,9 @@ function showMenu() {
|
||||
# OUTS: None
|
||||
################################################################################
|
||||
function optionPicked() {
|
||||
local -r bold=$(tput bold)
|
||||
local -r red=$(tput setaf 1)
|
||||
local -r reset=$(tput sgr0)
|
||||
local msg=${*:-"${reset}Error: No message passed"}
|
||||
local msg=${*:-"Error: No message passed"}
|
||||
|
||||
echo -e "${bold}${red}${msg}${reset}\n"
|
||||
echo -e "${msg}\n"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -380,11 +377,13 @@ function jsonOutput() {
|
||||
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}")
|
||||
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 " $i " | wc -l
|
||||
"$_since" "$_until" $_log_options | grep -E "($startYear|$endYear)" | grep " $i " | wc -l
|
||||
done | awk '{
|
||||
count[$1] = $2
|
||||
total += $2
|
||||
@@ -411,12 +410,14 @@ function commitsByMonth() {
|
||||
function commitsByWeekday() {
|
||||
optionPicked "Git commits by weekday:"
|
||||
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
|
||||
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 "$i " | wc -l
|
||||
"$_since" "$_until" $_log_options | grep -E "($startYear|$endYear)" | grep "$i " | wc -l
|
||||
counter=$((counter+1))
|
||||
done | awk '{
|
||||
}
|
||||
@@ -456,11 +457,14 @@ function commitsByHour() {
|
||||
_author="--author=${author}"
|
||||
fi
|
||||
echo -e "\thour\tsum"
|
||||
|
||||
local startYear=$(echo "$_since" | grep -Eo "[0-9]{4}")
|
||||
local endYear=$(echo "$_until" | grep -Eo "[0-9]{4}")
|
||||
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 ' '$i: | wc -l
|
||||
"${_author}" "$_since" "$_until" $_log_options | grep -E "($startYear|$endYear)" | grep ' '$i: | wc -l
|
||||
done | awk '{
|
||||
count[$1] = $2
|
||||
total += $2
|
||||
@@ -518,9 +522,9 @@ function commitsPerAuthor() {
|
||||
sum[author[i]]++; name[author[i]] = author[i]; total++;
|
||||
}
|
||||
for(i in sum) {
|
||||
printf "\t%d,%s,%2.1f%%\n", sum[i], name[i], (100 * sum[i] / total)
|
||||
printf "\t%d:%s:%2.1f%%\n", sum[i], name[i], (100 * sum[i] / total)
|
||||
}
|
||||
}' | sort -n -r | column -t -s,
|
||||
}' | sort -n -r | column -t -s:
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
||||
@@ -17,12 +17,16 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set -o nounset
|
||||
|
||||
export DISCOVERONLY=${DISCOVERONLY:-}
|
||||
export DEBUG=${DEBUG:-}
|
||||
export STOP=${STOP:-}
|
||||
export INVARIANT=${INVARIANT:-}
|
||||
export CONTINUE=${CONTINUE:-}
|
||||
|
||||
GREP=${GREP:-grep}
|
||||
|
||||
args="$(getopt -n "$0" -l \
|
||||
verbose,help,stop,discover,invariant,continue vhxdic $*)" \
|
||||
|| exit -1
|
||||
@@ -132,12 +136,12 @@ assert_raises() {
|
||||
_assert_with_grep() {
|
||||
local grep_modifier="$1"
|
||||
local output="$($2)"
|
||||
local exitcode="$4" || 0
|
||||
local exitcode=0
|
||||
shift 2
|
||||
|
||||
while [ $# != 0 ]; do
|
||||
assert_raises "echo '$output' | $GREP $grep_modifier '$1'" $exitcode || return 1
|
||||
shift
|
||||
assert_raises "echo '$output' | $GREP $grep_modifier '$1'" $exitcode || return 1
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
@@ -73,13 +73,13 @@ ADDITIONAL USAGE
|
||||
|
||||
assert_raises "$src fail" 1
|
||||
|
||||
assert_contains "$src --suggest-reviewers" "Suggested code reviewers (based on git history)" 127
|
||||
assert_contains "$src --suggest-reviewers" "Suggested code reviewers (based on git history)"
|
||||
assert_raises "$src --suggest-reviewers" 0
|
||||
|
||||
assert_contains "$src --detailed-git-stats" "Contribution stats" 127
|
||||
assert_contains "$src --detailed-git-stats" "Contribution stats"
|
||||
assert_raises "$src --detailed-git-stats" 0
|
||||
|
||||
assert_contains "$src --commits-per-day" "Git commits per date" 127
|
||||
assert_contains "$src --commits-per-day" "Git commits per date"
|
||||
assert_raises "$src --commits-per-day" 0
|
||||
|
||||
assert_end
|
||||
|
||||
Reference in New Issue
Block a user