mirror of
https://github.com/git-quick-stats/git-quick-stats.git
synced 2025-12-21 12:13:52 +01:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f95691967 | ||
|
|
36405591ec | ||
|
|
4e3f4ba826 | ||
|
|
83e96f8b80 | ||
|
|
206ebd8a76 | ||
|
|
2274ca1284 | ||
|
|
37f15f6381 | ||
|
|
337ead38e3 | ||
|
|
c38e4eb7b6 | ||
|
|
b767822eb3 | ||
|
|
08520bf068 | ||
|
|
374527dbe1 | ||
|
|
dba2d87206 | ||
|
|
8bfc58710a | ||
|
|
6f931ac9b5 | ||
|
|
42a657b0de | ||
|
|
a48347e0df | ||
|
|
f4930f152d | ||
|
|
e5727cf4e9 |
3
Makefile
3
Makefile
@@ -16,7 +16,8 @@ help:
|
||||
@$(TASK_DONE)
|
||||
|
||||
install:
|
||||
install -m 0755 $(EXEC_FILES) $(PREFIX)/bin
|
||||
mkdir -p $(PREFIX)/bin
|
||||
install -m 0755 $(EXEC_FILES) $(PREFIX)/bin/$(EXEC_FILES)
|
||||
git config --global alias.quick-stats '! $(PREFIX)/bin/$(EXEC_FILES)'
|
||||
@$(TASK_DONE)
|
||||
|
||||
|
||||
22
README.md
22
README.md
@@ -1,13 +1,13 @@
|
||||
|
||||
## 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)
|
||||
|
||||
[](https://travis-ci.org/arzzen/git-quick-stats)
|
||||
[](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-stats` is a simple and efficient way to access various statistics in git repository.
|
||||
|
||||
> Any git repository contains a tonne 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 – I don’t think there is a single person alive who knows them all. Probably not even [Linus Torvalds](https://github.com/torvalds) himself :).
|
||||
> 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 – 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
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* [**Windows**](#windows-cygwin)
|
||||
|
||||
[**Usage**](#usage)
|
||||
* [**Git log since/unitl**](#git-log-since-until)
|
||||
* [**Git log since/until**](#git-log-since-until)
|
||||
* [**Git log limit**](#git-log-limit)
|
||||
* [**Git pathspec**](#git-pathspec)
|
||||
* [**Tests**](#tests)
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
```bash
|
||||
git quick-stats
|
||||
# or
|
||||
# or
|
||||
git-quick-stats
|
||||
```
|
||||
|
||||
@@ -59,7 +59,7 @@ Or you can use (non-interactive) direct execution:
|
||||
|
||||
`git quick-stats <optional-command-to-execute-directly>`
|
||||
|
||||
Possible arguments:
|
||||
Possible arguments:
|
||||
> suggestReviewers, detailedGitStats, commitsByHour, commitsByWeekday, commitsByMonth, commitsPerDay, commitsPerAuthor, myDailyStats, contributors,
|
||||
branchTree, branchesByDate, changelogs, changelogsByAuthor
|
||||
|
||||
@@ -76,7 +76,7 @@ export _GIT_UNTIL="2017-22-01"
|
||||
then run `git quick-stats` (affect all stats, except "My daily status" and "Git changelogs" )
|
||||
|
||||
|
||||
#### Git log limit
|
||||
#### Git log limit
|
||||
|
||||
You can set variable `_GIT_LIMIT` for limited output (it will affect: "Git changelogs" and "Branch tree view" )
|
||||
|
||||
@@ -122,14 +122,14 @@ brew install git-quick-stats
|
||||
|
||||
#### Windows (cygwin)
|
||||
|
||||
* [installer](https://gist.github.com/arzzen/35e09866dfdadf2108b2420045739245)
|
||||
* [installer](https://gist.github.com/arzzen/35e09866dfdadf2108b2420045739245)
|
||||
* [uninstaller](https://gist.github.com/arzzen/21c660014d0663b6c5710014714779d6)
|
||||
|
||||
|
||||
## System requirements
|
||||
|
||||
* 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
|
||||
|
||||
@@ -141,16 +141,16 @@ brew install git-quick-stats
|
||||
|
||||
*A:* You can run dos2unix app in cygwin `/bin/dos2unix.exe /usr/local/bin/git-quick-stats`. This will convert it to Unix format and you then should be able to run it.
|
||||
|
||||
## Contribution
|
||||
## Contribution
|
||||
|
||||
Want to contribute? Great! First, read this page.
|
||||
|
||||
#### 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.
|
||||
|
||||
#### 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.
|
||||
* Write a descriptive commit message. What problem are you solving and what
|
||||
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/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<meta http-equiv="refresh" content="0;url=https://lukasmestan.com/git-quick-stats/">
|
||||
</head>
|
||||
<body id="page-top">
|
||||
<header>
|
||||
|
||||
183
git-quick-stats
183
git-quick-stats
@@ -4,70 +4,80 @@ set -o nounset
|
||||
set -o errexit
|
||||
|
||||
_since=${_GIT_SINCE:-}
|
||||
if [ ! -z ${_since} ]
|
||||
then _since="--since=$_since"
|
||||
fi
|
||||
[[ -n "${_since}" ]] && _since="--since=$_since"
|
||||
|
||||
_until=${_GIT_UNTIL:-}
|
||||
if [ ! -z ${_until} ]
|
||||
then _until="--until=$_until"
|
||||
fi
|
||||
[[ -n "${_until}" ]] && _until="--until=$_until"
|
||||
|
||||
_pathspec=${_GIT_PATHSPEC:-}
|
||||
if [ ! -z "${_pathspec}" ]
|
||||
then _pathspec="-- $_pathspec"
|
||||
fi
|
||||
[[ -n "${_pathspec}" ]] && _pathspec="-- $_pathspec"
|
||||
|
||||
|
||||
_limit=${_GIT_LIMIT:-}
|
||||
if [ ! -z ${_limit} ]
|
||||
if [[ -n "${_limit}" ]];
|
||||
then _limit=$_limit
|
||||
else
|
||||
_limit=10
|
||||
fi
|
||||
|
||||
function show_menu() {
|
||||
NORMAL=`echo "\033[m"`
|
||||
MENU=`echo "\033[36m"`
|
||||
NUMBER=`echo "\033[33m"`
|
||||
FGRED=`echo "\033[41m"`
|
||||
RED_TEXT=`echo "\033[31m"`
|
||||
ENTER_LINE=`echo "\033[33m"`
|
||||
function check_utils() {
|
||||
local HELP_MSG="not found. Please make sure this is installed and in PATH."
|
||||
|
||||
echo -e ""
|
||||
echo -e "${RED_TEXT} Generate: ${NORMAL}"
|
||||
echo -e "${MENU} ${NUMBER} 1)${MENU} Contribution stats (by author) ${NORMAL}"
|
||||
echo -e "${MENU} ${NUMBER} 2)${MENU} Git changelogs (last $_limit)${NORMAL}"
|
||||
echo -e "${MENU} ${NUMBER} 3)${MENU} Git changelogs by author ${NORMAL}"
|
||||
echo -e "${MENU} ${NUMBER} 4)${MENU} My daily status ${NORMAL}"
|
||||
command -v awk >/dev/null 2>&1 || { echo >&2 "awk ${HELP_MSG}"; exit 1; }
|
||||
command -v cat > /dev/null 2>&1 || { echo >&2 "cat ${HELP_MSG}"; exit 1; }
|
||||
command -v column > /dev/null 2>&1 || { echo >&2 "column ${HELP_MSG}"; exit 1; }
|
||||
command -v echo > /dev/null 2>&1 || { echo >&2 "echo ${HELP_MSG}"; exit 1; }
|
||||
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 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 "${MENU} ${NUMBER} 5)${MENU} Branch tree view (last $_limit)${NORMAL}"
|
||||
echo -e "${MENU} ${NUMBER} 6)${MENU} All branches (sorted by most recent commit) ${NORMAL}"
|
||||
echo -e "${MENU} ${NUMBER} 7)${MENU} All contributors (sorted by name) ${NORMAL}"
|
||||
echo -e "${MENU} ${NUMBER} 8)${MENU} Git commits per author ${NORMAL}"
|
||||
echo -e "${MENU} ${NUMBER} 9)${MENU} Git commits per date ${NORMAL}"
|
||||
echo -e "${MENU} ${NUMBER} 10)${MENU} Git commits per month ${NORMAL}"
|
||||
echo -e "${MENU} ${NUMBER} 11)${MENU} Git commits per weekday ${NORMAL}"
|
||||
echo -e "${MENU} ${NUMBER} 12)${MENU} Git commits per hour ${NORMAL}"
|
||||
echo -e "${MENU} ${NUMBER} 13)${MENU} Git commits by author per hour ${NORMAL}"
|
||||
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 5)${CYAN_TEXT} Branch tree view (last $_limit)${NORMAL}"
|
||||
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 6)${CYAN_TEXT} All branches (sorted by most recent commit) ${NORMAL}"
|
||||
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 7)${CYAN_TEXT} All contributors (sorted by name) ${NORMAL}"
|
||||
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 8)${CYAN_TEXT} Git commits per author ${NORMAL}"
|
||||
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 9)${CYAN_TEXT} Git commits per date ${NORMAL}"
|
||||
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 10)${CYAN_TEXT} Git commits per month ${NORMAL}"
|
||||
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 11)${CYAN_TEXT} Git commits per weekday ${NORMAL}"
|
||||
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 12)${CYAN_TEXT} Git commits 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 "${MENU} ${NUMBER} 14)${MENU} Code reviewers (based on git history) ${NORMAL}"
|
||||
echo -e ""
|
||||
echo -e "${ENTER_LINE}Please enter a menu option or ${RED_TEXT}press enter to exit. ${NORMAL}"
|
||||
read opt
|
||||
echo -e "${CYAN_TEXT} ${YELLOW_TEXT} 14)${CYAN_TEXT} Code reviewers (based on git history) ${NORMAL}"
|
||||
echo -e "\n${YELLOW_TEXT}Please enter a menu option or ${RED_TEXT}press enter to exit. ${NORMAL}"
|
||||
read -r opt
|
||||
}
|
||||
|
||||
function option_picked() {
|
||||
COLOR='\033[01;31m'
|
||||
RESET='\033[00;00m'
|
||||
MESSAGE=${@:-"${RESET}Error: No message passed"}
|
||||
echo -e "${COLOR}${MESSAGE}${RESET}"
|
||||
echo ""
|
||||
local BOLD=$(tput bold)
|
||||
local RED_TEXT=$(tput setaf 1)
|
||||
local COLOR="${BOLD}${RED_TEXT}"
|
||||
local RESET=$(tput sgr0)
|
||||
local MESSAGE=${*:-"${RESET}Error: No message passed"}
|
||||
|
||||
echo -e "${COLOR}${MESSAGE}${RESET}\n"
|
||||
}
|
||||
|
||||
function detailedGitStats() {
|
||||
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) {
|
||||
printf "\t%s:\n", author
|
||||
|
||||
@@ -97,7 +107,8 @@ function detailedGitStats() {
|
||||
}
|
||||
|
||||
/^Author:/ {
|
||||
author = $2 " " $3
|
||||
$1 = ""
|
||||
author = $0
|
||||
commits[author] += 1
|
||||
commits["total"] += 1
|
||||
}
|
||||
@@ -153,12 +164,13 @@ function commitsByMonth() {
|
||||
END{
|
||||
for (month in count) {
|
||||
s="|";
|
||||
percent = ((count[month] / total) * 100) / 1.25;
|
||||
for (i = 1; i <= percent; ++i) {
|
||||
s=s"█"
|
||||
if (total > 0) {
|
||||
percent = ((count[month] / total) * 100) / 1.25;
|
||||
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
|
||||
}
|
||||
@@ -182,29 +194,33 @@ function commitsByWeekday() {
|
||||
|
||||
for (day in count) {
|
||||
s="|";
|
||||
percent = ((count[day] / total) * 100) / 1.25;
|
||||
for (i = 1; i <= percent; ++i) {
|
||||
s=s"█"
|
||||
if (total > 0) {
|
||||
percent = ((count[day] / total) * 100) / 1.25;
|
||||
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
|
||||
}
|
||||
|
||||
function commitsByHour() {
|
||||
local author="${1:-}"
|
||||
local _author=''
|
||||
if [ -z "$author" ]; then
|
||||
local _author=""
|
||||
|
||||
if [[ -z "${author}" ]]; then
|
||||
option_picked "Git commits by hour:"
|
||||
_author="--author=**"
|
||||
else
|
||||
option_picked "Git commits by hour for author '$author':"
|
||||
_author="--author=$author"
|
||||
option_picked "Git commits by hour for author '${author}':"
|
||||
_author="--author=${author}"
|
||||
fi
|
||||
echo -e "\thour\tsum"
|
||||
for i in `seq -w 0 23`
|
||||
for i in $(seq -w 0 23)
|
||||
do
|
||||
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 '{
|
||||
count[$1] = $2
|
||||
total += $2
|
||||
@@ -212,11 +228,13 @@ function commitsByHour() {
|
||||
END{
|
||||
for (hour in count) {
|
||||
s="|";
|
||||
percent = ((count[hour] / total) * 100) / 1.25;
|
||||
for (i = 1; i <= percent; ++i) {
|
||||
s=s"█"
|
||||
if (total > 0) {
|
||||
percent = ((count[hour] / total) * 100) / 1.25;
|
||||
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
|
||||
}
|
||||
@@ -268,23 +286,28 @@ function branchesByDate() {
|
||||
|
||||
function changelogs() {
|
||||
local author="${1:-}"
|
||||
local _author=''
|
||||
if [ -z "$author" ]; then
|
||||
local _author=""
|
||||
|
||||
if [[ -z "${author}" ]]; then
|
||||
option_picked "Git changelogs:"
|
||||
_author="--author=**"
|
||||
else
|
||||
option_picked "Git changelogs for author '$author':"
|
||||
_author="--author=$author"
|
||||
option_picked "Git changelogs for author '${author}':"
|
||||
_author="--author=${author}"
|
||||
fi
|
||||
|
||||
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 "[$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
|
||||
done
|
||||
}
|
||||
|
||||
# Check to make sure all utilities required for this script are installed
|
||||
check_utils
|
||||
|
||||
# Check if we are currently in a git repo.
|
||||
git rev-parse --is-inside-work-tree > /dev/null
|
||||
|
||||
@@ -320,8 +343,8 @@ if [ $# -eq 1 ]
|
||||
;;
|
||||
"changelogsByAuthor")
|
||||
author="${_GIT_AUTHOR:-}"
|
||||
while [ -z "$author" ]; do read -p "Which author? " author; done
|
||||
changelogs "$author"
|
||||
while [ -z "${author}" ]; do read -p "Which author? " author; done
|
||||
changelogs "${author}"
|
||||
;;
|
||||
"commitsByWeekday")
|
||||
commitsByWeekday
|
||||
@@ -331,8 +354,8 @@ if [ $# -eq 1 ]
|
||||
;;
|
||||
"commitsByAuthorByHour")
|
||||
author="${_GIT_AUTHOR:-}"
|
||||
while [ -z "$author" ]; do read -p "Which author? " author; done
|
||||
commitsByHour "$author"
|
||||
while [ -z "${author}" ]; do read -p "Which author? " author; done
|
||||
commitsByHour "${author}"
|
||||
;;
|
||||
"commitsByMonth")
|
||||
commitsByMonth
|
||||
@@ -345,11 +368,7 @@ if [ $# -eq 1 ]
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
if [ $# -gt 1 ]
|
||||
then
|
||||
echo "Usage: git quick-stats <optional-command-to-execute-directly>";
|
||||
exit 1;
|
||||
fi
|
||||
[[ $# -gt 1 ]] && { echo "Usage: git quick-stats <optional-command-to-execute-directly>"; exit 1; }
|
||||
|
||||
clear
|
||||
show_menu
|
||||
@@ -371,8 +390,8 @@ while [ opt != '' ]
|
||||
;;
|
||||
3)
|
||||
author=''
|
||||
while [ -z "$author" ]; do read -p "Which author? " author; done
|
||||
changelogs "$author"
|
||||
while [ -z "${author}" ]; do read -p "Which author? " author; done
|
||||
changelogs "${author}"
|
||||
show_menu
|
||||
;;
|
||||
4)
|
||||
@@ -413,8 +432,8 @@ while [ opt != '' ]
|
||||
;;
|
||||
13)
|
||||
author=''
|
||||
while [ -z "$author" ]; do read -p "Which author? " author; done
|
||||
commitsByHour "$author"
|
||||
while [ -z "${author}" ]; do read -p "Which author? " author; done
|
||||
commitsByHour "${author}"
|
||||
show_menu
|
||||
;;
|
||||
14)
|
||||
|
||||
Reference in New Issue
Block a user