Compare commits

...

17 Commits
1.0.1 ... 1.0.5

Author SHA1 Message Date
Lukas Mestan
d2fe6fe5ce bugfix tree view 2017-03-18 12:09:17 +01:00
Lukáš Mešťan
8f5dd5bed7 Merge pull request #26 from bpkroth/add-commitsByAuthorByHour-support 2017-03-18 12:06:21 +01:00
Brian Kroth
d4f09f23be adapts commitsByHour to allow reporting by author as well 2017-03-17 10:53:25 -05:00
Lukáš Mešťan
89a62ebe06 remove dot in pathspec 2017-03-17 07:30:29 +01:00
Lukáš Mešťan
481bc47482 rename variable _exclude to _pathspec 2017-03-16 11:43:48 +01:00
Lukas Mestan
29bbc98c87 rename _GIT_EXCLUDE to _GIT_PATHSPEC 2017-03-15 20:11:56 +01:00
Lukas Mestan
f344f0dfb7 quote ${_exclude} 2017-03-15 19:09:07 +01:00
Lukas Mestan
8b24e28c95 add _GIT_EXCLUDE, #25 2017-03-15 18:51:00 +01:00
Lukas Mestan
745b995f30 update inline graph 2017-03-07 19:09:36 +01:00
Lukas Mestan
1a7abe3132 fix #24, sort commits by weekday 2017-02-28 20:15:17 +01:00
Lukas Mestan
5a55f87ad7 update readme 2017-02-22 20:11:26 +01:00
Lukas Mestan
11c1a9ff5c add limit option for changelogs & branch tree view 2017-02-22 20:05:05 +01:00
Lukáš Mešťan
06563a2170 🍺 homebrew installation 2017-02-21 21:09:47 +01:00
Lukas Mestan
2e9b163766 remove white spaces 2017-02-21 20:36:08 +01:00
Lukas Mestan
8558eef324 update readme 2017-02-21 19:20:44 +00:00
Lukáš Mešťan
6d0e1aa692 Merge pull request #22 from xdlbx/add-november
added november to the list of months, thanks @xdlbx
2017-02-18 11:39:37 +01:00
Dustin Blomquist
27f0857b77 added november to the list of months 2017-02-18 01:08:10 -06:00
2 changed files with 91 additions and 31 deletions

View File

@@ -32,6 +32,8 @@ Or you can use (non-interactive) direct execution:
branchTree, branchesByDate, changelogs
#### Git log --since and --until arguments
You can set variable `_GIT_SINCE`, `_GIT_UNTIL` and limit the git log
eg:
@@ -42,8 +44,20 @@ eg:
then run `git quick-stats` (affect all stats, except "My daily status" and "Git changelogs" )
#### Git log limit
You can set variable `_GIT_LIMIT` for limited output (it will affect: "Git changelogs" and "Branch tree view" )
eg:
`export _GIT_LIMIT=20`
## Installation
#### Unix like OS
```
git clone https://github.com/arzzen/git-quick-stats.git && cd git-quick-stats
sudo make install
@@ -55,11 +69,16 @@ For uninstalling, open up the cloned directory and run
sudo make uninstall
```
#### Cygwin installation
#### OS X (homebrew)
`brew install git-quick-stats`
#### Windows (cygwin)
* [installer](https://gist.github.com/arzzen/35e09866dfdadf2108b2420045739245)
* [uninstaller](https://gist.github.com/arzzen/21c660014d0663b6c5710014714779d6)
## System requirements
* Unix like OS with a proper shell

View File

@@ -13,6 +13,18 @@ if [ ! -z ${_until} ]
then _until="--until=$_until"
fi
_pathspec=${_GIT_PATHSPEC:-}
if [ ! -z "${_pathspec}" ]
then _pathspec="-- $_pathspec"
fi
_limit=${_GIT_LIMIT:-}
if [ ! -z ${_limit} ]
then _limit=$_limit
else
_limit=10
fi
show_menu() {
NORMAL=`echo "\033[m"`
MENU=`echo "\033[36m"`
@@ -24,10 +36,10 @@ show_menu() {
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 ${NORMAL}"
echo -e "${MENU} ${NUMBER} 2)${MENU} Git changelogs (last $_limit)${NORMAL}"
echo -e "${MENU} ${NUMBER} 3)${MENU} My daily status ${NORMAL}"
echo -e "${RED_TEXT} List: ${NORMAL}"
echo -e "${MENU} ${NUMBER} 4)${MENU} Branch tree view (last 10)${NORMAL}"
echo -e "${MENU} ${NUMBER} 4)${MENU} Branch tree view (last $_limit)${NORMAL}"
echo -e "${MENU} ${NUMBER} 5)${MENU} All branches (sorted by most recent commit) ${NORMAL}"
echo -e "${MENU} ${NUMBER} 6)${MENU} All contributors (sorted by name) ${NORMAL}"
echo -e "${MENU} ${NUMBER} 7)${MENU} Git commits per author ${NORMAL}"
@@ -35,8 +47,9 @@ show_menu() {
echo -e "${MENU} ${NUMBER} 9)${MENU} Git commits per month ${NORMAL}"
echo -e "${MENU} ${NUMBER} 10)${MENU} Git commits per weekday ${NORMAL}"
echo -e "${MENU} ${NUMBER} 11)${MENU} Git commits per hour ${NORMAL}"
echo -e "${MENU} ${NUMBER} 12)${MENU} Git commits by author per hour ${NORMAL}"
echo -e "${RED_TEXT} Suggest: ${NORMAL}"
echo -e "${MENU} ${NUMBER} 12)${MENU} Code reviewers (based on git history) ${NORMAL}"
echo -e "${MENU} ${NUMBER} 13)${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
@@ -53,7 +66,7 @@ function option_picked() {
function detailedGitStats() {
option_picked "Contribution stats (by author):"
git log --no-merges --numstat --pretty="format:commit %H%nAuthor: %an <%ae>%nDate: %ad%n%n%w(0,4,4)%B%n" $_since $_until | LC_ALL=C awk '
git log --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
@@ -74,6 +87,7 @@ function detailedGitStats() {
}
if ( first[author] != "" ) {
printf "\t lines changed: %s\n", more[author] + less[author]
printf "\t first commit: %s\n", first[author]
printf "\t last commit: %s\n", last[author]
}
@@ -115,7 +129,7 @@ function detailedGitStats() {
function suggestReviewers() {
option_picked "Suggested code reviewers (based on git history):"
git log --no-merges $_since $_until --pretty=%an $* | head -n 100 | sort | uniq -c | sort -nr | LC_ALL=C awk '
git log --no-merges $_since $_until --pretty=%an $_pathspec $* | head -n 100 | sort | uniq -c | sort -nr | LC_ALL=C awk '
{ args[NR] = $0; }
END {
for (i = 1; i <= NR; ++i) {
@@ -127,7 +141,7 @@ function suggestReviewers() {
function commitsByMonth() {
option_picked "Git commits by month:"
echo -e "\tmonth\tsum"
for i in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Dec
for i in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
do
echo -en "\t$i\t"
echo $(git shortlog -n --no-merges --format='%ad %s' $_since $_until | grep " $i " | wc -l)
@@ -137,12 +151,13 @@ function commitsByMonth() {
}
END{
for (month in count) {
s="";
s="|";
percent = ((count[month] / total) * 100) / 1.25;
for (i = 1; i <= percent; ++i) {
s=s"="
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
}
@@ -154,52 +169,60 @@ function commitsByWeekday() {
do
echo -en "\t$i\t"
echo $(git shortlog -n --no-merges --format='%ad %s' $_since $_until | grep "$i " | wc -l)
done | awk '{
}
done | awk '{
}
NR == FNR {
count[$1] = $2;
total += $2;
next
}
END{
for (day in count) {
s="";
s="|";
percent = ((count[day] / total) * 100) / 1.25;
for (i = 1; i <= percent; ++i) {
s=s"="
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() {
option_picked "Git commits by hour:"
local author="${1:-}"
local _author=''
if [ -z "$author" ]; then
option_picked "Git commits by hour:"
else
option_picked "Git commits by hour for author '$author':"
_author="--author=$author"
fi
echo -e "\thour\tsum"
for i in `seq -w 0 23`
do
echo -ne "\t$i\t"
echo $(git shortlog -n --no-merges --format='%ad %s' $_since $_until | grep " $i:" | wc -l)
echo $(git shortlog -n --no-merges --format='%ad %s' $_author $_since $_until | grep " $i:" | wc -l)
done | awk '{
count[$1] = $2
total += $2
}
END{
for (hour in count) {
s="";
s="|";
percent = ((count[hour] / total) * 100) / 1.25;
for (i = 1; i <= percent; ++i) {
s=s"="
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
}
function commitsPerDay() {
option_picked "Git commits per date:";
git log --no-merges $_since $_until --date=short --format='%ad' | sort | uniq -c
git log --no-merges $_since $_until --date=short --format='%ad' $_pathspec | sort | uniq -c
}
function commitsPerAuthor() {
@@ -228,12 +251,12 @@ function myDailyStats() {
function contributors() {
option_picked "All contributors (sorted by name):"
git log --no-merges $_since $_until --format='%aN' | sort -u | cat -n
git log --no-merges $_since $_until --format='%aN' $_pathspec | sort -u | cat -n
}
function branchTree() {
option_picked "Branching tree view:"
git log --graph --abbrev-commit $_since $_until --decorate --format=format:'--+ Commit: %h %n | Date: %aD (%ar) %n'' | Message: %s %d %n'' + Author: %an %n' --all | head -n 50
git log --graph --abbrev-commit $_since $_until --decorate --format=format:'--+ Commit: %h %n | Date: %aD (%ar) %n'' | Message: %s %d %n'' + Author: %an %n' --all | head -n $((_limit*5))
}
@@ -244,7 +267,14 @@ function branchesByDate() {
function changelogs() {
option_picked "Git changelogs:"
git log --pretty=format:"- %s%n%b" --since="$(git show -s --format=%ad `git rev-list --all --max-count=1`)" | sort -nr
NEXT=$(date +%F)
git log --no-merges --format="%cd" --date=short $_since $_until $_pathspec | sort -u -r | head -n $_limit | while read DATE ; do
echo
echo "[$DATE]"
GIT_PAGER=cat git log --no-merges --format=" * %s" --since=$DATE --until=$NEXT
NEXT=$DATE
done
}
# Check if we are currently in a git repo.
@@ -286,11 +316,16 @@ if [ $# -eq 1 ]
"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, commitsPerAuthor, myDailyStats, contributors, branchTree, branchesByDate, changelogs"
echo "Invalid argument. Possible arguments: suggestReviewers, detailedGitStats, commitsPerDay, commitsByMonth, commitsByWeekday, commitsByHour, commitsByAuthorByHour, commitsPerAuthor, myDailyStats, contributors, branchTree, branchesByDate, changelogs"
;;
esac
exit 0;
@@ -330,7 +365,7 @@ while [ opt != '' ]
;;
5)
branchesByDate
show_menu
show_menu
;;
6)
contributors
@@ -357,17 +392,23 @@ while [ opt != '' ]
show_menu
;;
12)
author=''
while [ -z "$author" ]; do read -p "Which author? " author; done
commitsByHour "$author"
show_menu
;;
13)
suggestReviewers
show_menu
;;
q)
exit
exit
;;
\n)
exit
exit
;;
*)
clear
clear
option_picked "Pick an option from the menu"
show_menu
;;