small changes

This commit is contained in:
arzzen 2017-01-17 20:23:33 +01:00
parent 7ded29df6b
commit a9380ec5a4

View file

@ -1,8 +1,10 @@
#!/bin/bash
#!/usr/bin/env bash
set -o nounset
set -o errexit
project=${PWD##*/}
show_menu() {
NORMAL=`echo "\033[m"`
MENU=`echo "\033[36m"`
@ -34,25 +36,32 @@ function option_picked() {
function detailedGitStats() {
option_picked "Detailed stats per author, including contribution to the total change:"
git log --no-merges --numstat | awk '
echo ""
git log --no-merges --numstat | LC_ALL=C awk '
function printStats(author) {
printf "%s:\n", author
printf " first -> last: %s -> %s \n", first[author] , last[author]
printf " insertions: %d (%.0f%%)\n", more[author], (more[author] / more["total"] * 100)
printf " deletions: %d (%.0f%%)\n", less[author], (less[author] / less["total"] * 100)
printf " files: %d (%.0f%%)\n", file[author], (file[author] / file["total"] * 100)
printf " commits: %d (%.0f%%)\n", commits[author], (commits[author] / commits["total"] * 100)
printf "\t%s:\n", author
printf "\t insertions: %d (%.0f%%)\n", more[author], (more[author] / more["total"] * 100)
printf "\t deletions: %d (%.0f%%)\n", less[author], (less[author] / less["total"] * 100)
printf "\t files: %d (%.0f%%)\n", file[author], (file[author] / file["total"] * 100)
printf "\t commits: %d (%.0f%%)\n", commits[author], (commits[author] / commits["total"] * 100)
if ( first[author] != "" ) {
printf "\t first commit: %s\n", first[author]
printf "\t last commit: %s\n", last[author]
}
printf "\n"
}
/^Author:/ {
author = $2 " " $3
author = $2 " " $3
commits[author] += 1
commits["total"] += 1
commits["total"] += 1
}
/^Date:/ {
$1="";
$1="";
first[author] = substr($0, 2)
if(last[author] == "" ) { last[author] = first[author] }
}
@ -79,36 +88,61 @@ function detailedGitStats() {
function suggestReviewers() {
option_picked "Suggest code reviewers based on git history:"
git log --no-merges --pretty=%an $* | head -n 100 | sort | uniq -c | sort -nr
echo ""
git log --no-merges --pretty=%an $* | head -n 100 | sort | uniq -c | sort -nr | LC_ALL=C awk '
{ args[NR] = $0; }
END {
for (i = 1; i <= NR; ++i) {
printf "%s\n", args[i]
}
}' | column -t -s,
}
function commitsPerDay() {
option_picked "Git commits per day:";
echo ""
git log --no-merges --date=short --format='%ad' | sort | uniq -c
}
function commitsPerAuthor() {
option_picked "Git commits per author:"
git shortlog --no-merges -s -n | sort -nr
echo ""
git shortlog --no-merges -n -s | sort -nr | LC_ALL=C awk '
{ args[NR] = $0; sum += $0 }
END {
for (i = 1; i <= NR; ++i) {
printf "%s,%2.1f%%\n", args[i], 100 * args[i] / sum
}
}' | column -t -s,
}
function myDailyStats() {
option_picked "My daily status:"
git diff --shortstat "@{0 day ago}" | sort -nr
echo ""
git diff --shortstat '@{0 day ago}' | sort -nr | tr ',' '\n' | LC_ALL=C awk '
{ args[NR] = $0; }
END {
for (i = 1; i <= NR; ++i) {
printf "\t%s\n", args[i]
}
}'
}
function contributors() {
option_picked "List repository contributors by author name (sorted by name):"
git log --no-merges --format='%aN' | sort -u
echo ""
git log --no-merges --format='%aN' | sort -u | cat -n
}
function branchesByDate() {
option_picked "List of all the branches, ordered by most recent commits:"
git for-each-ref --sort=committerdate refs/heads/ --format='[%(authordate:relative)] %(authorname) %(color:yellow)%(refname:short)%(color:reset)'
echo ""
git for-each-ref --sort=committerdate refs/heads/ --format='[%(authordate:relative)] %(authorname) %(color:yellow)%(refname:short)%(color:reset)' | cat -n
}
function changelogs() {
option_picked "Generate git changelogs:"
echo ""
git log --pretty=format:"- %s%n%b" --since="$(git show -s --format=%ad `git rev-list --all --max-count=1`)" | sort -nr
}