mirror of
https://github.com/git-quick-stats/git-quick-stats.git
synced 2025-12-21 12:13:52 +01:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2fe6fe5ce | ||
|
|
8f5dd5bed7 | ||
|
|
d4f09f23be | ||
|
|
89a62ebe06 | ||
|
|
481bc47482 | ||
|
|
29bbc98c87 | ||
|
|
f344f0dfb7 | ||
|
|
8b24e28c95 | ||
|
|
745b995f30 | ||
|
|
1a7abe3132 |
@@ -13,6 +13,11 @@ 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
|
||||
@@ -42,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
|
||||
@@ -60,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
|
||||
|
||||
@@ -81,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]
|
||||
}
|
||||
@@ -122,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) {
|
||||
@@ -144,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
|
||||
}
|
||||
@@ -170,43 +178,51 @@ function commitsByWeekday() {
|
||||
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() {
|
||||
@@ -235,7 +251,7 @@ 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() {
|
||||
@@ -253,7 +269,7 @@ function changelogs() {
|
||||
option_picked "Git changelogs:"
|
||||
NEXT=$(date +%F)
|
||||
|
||||
git log --no-merges --format="%cd" --date=short $_since $_until | sort -u -r | head -n $_limit | while read DATE ; do
|
||||
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
|
||||
@@ -300,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;
|
||||
@@ -371,6 +392,12 @@ while [ opt != '' ]
|
||||
show_menu
|
||||
;;
|
||||
12)
|
||||
author=''
|
||||
while [ -z "$author" ]; do read -p "Which author? " author; done
|
||||
commitsByHour "$author"
|
||||
show_menu
|
||||
;;
|
||||
13)
|
||||
suggestReviewers
|
||||
show_menu
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user