mirror of
https://github.com/git-quick-stats/git-quick-stats.git
synced 2025-12-21 12:13:52 +01:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7219205696 | ||
|
|
dd3c97816e | ||
|
|
d2b273eead |
14
README.md
14
README.md
@@ -5,7 +5,7 @@
|
||||
>
|
||||
> Any git repository may contain tons of information about commits, contributors, and files. Extracting this information is not always trivial, mostly because there are 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
|
||||
|
||||
@@ -53,15 +53,15 @@
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
### Interactive
|
||||
|
||||
git-quick-stats has a built-in interactive menu that can be executed as such:
|
||||
`git-quick-stats` has a built-in interactive menu that can be executed as such:
|
||||
|
||||
```bash
|
||||
git-quick-stats
|
||||
@@ -98,6 +98,8 @@ Possible arguments in short and long form:
|
||||
give a detailed list of git stats
|
||||
-R, --git-stats-by-branch
|
||||
see detailed list of git stats by branch
|
||||
-V, --csv-output-by-branch
|
||||
output daily stats by branch in CSV format
|
||||
-d, --commits-per-day
|
||||
displays a list of commits per day
|
||||
-m, --commits-by-month
|
||||
@@ -180,7 +182,7 @@ export _GIT_MERGE_VIEW="exclusive"
|
||||
|
||||
### Git branch
|
||||
|
||||
You can set the variable `_GIT_BRANCH` to set the branch of the stats. Works with commands `--git-stats-by-branch`.
|
||||
You can set the variable `_GIT_BRANCH` to set the branch of the stats. Works with commands `--git-stats-by-branch` and `--csv-output-by-branch`.
|
||||
|
||||
```bash
|
||||
export _GIT_BRANCH="master"
|
||||
@@ -194,7 +196,7 @@ You can change to the legacy color scheme by toggling the variable `_MENU_THEME`
|
||||
export _MENU_THEME=legacy
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
150
git-quick-stats
150
git-quick-stats
@@ -115,6 +115,8 @@ OPTIONS
|
||||
give a detailed list of git stats
|
||||
-R, --git-stats-by-branch
|
||||
see detailed list of git stats by branch
|
||||
-V, --csv-output-by-branch
|
||||
output daily stats by branch in CSV format
|
||||
-d, --commits-per-day
|
||||
displays a list of commits per day
|
||||
-m, --commits-by-month
|
||||
@@ -202,19 +204,20 @@ showMenu() {
|
||||
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 "${NUMS} 6)${TEXT} Output daily stats by branch in CSV format\\n"
|
||||
printf %b "${NUMS} 7)${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 "${NUMS} 8)${TEXT} Branch tree view (last $_limit)\\n"
|
||||
printf %b "${NUMS} 9)${TEXT} All branches (sorted by most recent commit)\\n"
|
||||
printf %b "${NUMS} 10)${TEXT} All contributors (sorted by name)\\n"
|
||||
printf %b "${NUMS} 11)${TEXT} Git commits per author\\n"
|
||||
printf %b "${NUMS} 12)${TEXT} Git commits per date\\n"
|
||||
printf %b "${NUMS} 13)${TEXT} Git commits per month\\n"
|
||||
printf %b "${NUMS} 14)${TEXT} Git commits per weekday\\n"
|
||||
printf %b "${NUMS} 15)${TEXT} Git commits per hour\\n"
|
||||
printf %b "${NUMS} 16)${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 "${NUMS} 17)${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
|
||||
@@ -231,6 +234,98 @@ function optionPicked() {
|
||||
echo -e "${msg}\n"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# DESC: Shows detailed contribution stats per author by parsing every commit in
|
||||
# the repo and outputting their contribution stats
|
||||
# ARGS: $branch (optional): Users can specify an alternative branch instead of
|
||||
# the current default one
|
||||
# OUTS: None
|
||||
################################################################################
|
||||
function csvOutput() {
|
||||
local is_branch_existing=false
|
||||
local branch="${1:-}"
|
||||
local _branch=""
|
||||
|
||||
# Check if requesting for a specific branch
|
||||
if [[ -n "${branch}" ]]; then
|
||||
# Check if branch exist
|
||||
if [[ $(git show-ref refs/heads/"${branch}") ]] ; then
|
||||
is_branch_existing=true
|
||||
_branch="${branch}"
|
||||
else
|
||||
is_branch_existing=false
|
||||
_branch=""
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "author,insertions,insertions_per,deletions,deletions_per,files,files_per,commits,commits_per,lines_changed,lines_changed_per"
|
||||
git -c log.showSignature=false log ${_branch} --use-mailmap $_merges --numstat \
|
||||
--pretty="format:commit %H%nAuthor: %aN <%aE>%nDate: %ad%n%n%w(0,4,4)%B%n" \
|
||||
"$_since" "$_until" $_log_options $_pathspec | LC_ALL=C awk '
|
||||
function printStats(author) {
|
||||
printf "%s,", author
|
||||
if(more["total"] > 0) {
|
||||
printf "%d,%.0f%%,", more[author], \
|
||||
(more[author] / more["total"] * 100)
|
||||
}
|
||||
|
||||
if(less["total"] > 0) {
|
||||
printf "%d,%.0f%%,", less[author], \
|
||||
(less[author] / less["total"] * 100)
|
||||
}
|
||||
|
||||
if(file["total"] > 0) {
|
||||
printf "%d,%.0f%%,", file[author], \
|
||||
(file[author] / file["total"] * 100)
|
||||
}
|
||||
|
||||
if(commits["total"] > 0) {
|
||||
printf "%d,%.0f%%,", commits[author], \
|
||||
(commits[author] / commits["total"] * 100)
|
||||
}
|
||||
|
||||
if (first[author] != "") {
|
||||
if ( ((more["total"] + less["total"]) * 100) > 0) {
|
||||
printf "%d,", more[author] + less[author]
|
||||
printf "%.0f%%\n", ((more[author] + less[author]) / \
|
||||
(more["total"] + less["total"]) * 100)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/^Author:/ {
|
||||
$1 = ""
|
||||
author = $0
|
||||
commits[author] += 1
|
||||
commits["total"] += 1
|
||||
}
|
||||
|
||||
/^Date:/ {
|
||||
$1="";
|
||||
first[author] = substr($0, 2)
|
||||
if(last[author] == "" ) { last[author] = first[author] }
|
||||
}
|
||||
|
||||
/^[0-9]/ {
|
||||
more[author] += $1
|
||||
less[author] += $2
|
||||
|
||||
file[author] += 1
|
||||
more["total"] += $1
|
||||
less["total"] += $2
|
||||
file["total"] += 1
|
||||
}
|
||||
|
||||
END {
|
||||
for (author in commits) {
|
||||
if (author != "total") {
|
||||
printStats(author)
|
||||
}
|
||||
}
|
||||
|
||||
}'
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# DESC: Shows detailed contribution stats per author by parsing every commit in
|
||||
# the repo and outputting their contribution stats
|
||||
@@ -640,6 +735,12 @@ if [[ "$#" -eq 1 ]]; then
|
||||
read -r -p "Which branch? " branch
|
||||
done
|
||||
detailedGitStats "${branch}";;
|
||||
-V|--csv-output-by-branch)
|
||||
branch="${_GIT_BRANCH:-}"
|
||||
while [[ -z "${branch}" ]]; do
|
||||
read -r -p "Which branch? " branch
|
||||
done
|
||||
csvOutput "${branch}";;
|
||||
-b|--branch-tree) branchTree;;
|
||||
-d|--commits-per-day) commitsPerDay;;
|
||||
-a|--commits-per-author) commitsPerAuthor;;
|
||||
@@ -707,7 +808,12 @@ while [[ "${opt}" != "" ]]; do
|
||||
done
|
||||
changelogs "${author}"; showMenu;;
|
||||
5) myDailyStats; showMenu;;
|
||||
6) json_path=""
|
||||
6) branch=""
|
||||
while [[ -z "${branch}" ]]; do
|
||||
read -r -p "Which branch? " branch
|
||||
done
|
||||
csvOutput "${branch}"; showMenu;;
|
||||
7) json_path=""
|
||||
while [[ -z "${json_path}" ]]; do
|
||||
echo "NOTE: This feature is in beta!"
|
||||
echo "The file name will be saved as \"output.json\"."
|
||||
@@ -724,20 +830,20 @@ while [[ "${opt}" != "" ]]; do
|
||||
fi
|
||||
done
|
||||
jsonOutput "${json_path}"; showMenu;;
|
||||
7) branchTree; showMenu;;
|
||||
8) branchesByDate; showMenu;;
|
||||
9) contributors; showMenu;;
|
||||
10) commitsPerAuthor; showMenu;;
|
||||
11) commitsPerDay; showMenu;;
|
||||
12) commitsByMonth; showMenu;;
|
||||
13) commitsByWeekday; showMenu;;
|
||||
14) commitsByHour; showMenu;;
|
||||
15) author=""
|
||||
8) branchTree; showMenu;;
|
||||
9) branchesByDate; showMenu;;
|
||||
10) contributors; showMenu;;
|
||||
11) commitsPerAuthor; showMenu;;
|
||||
12) commitsPerDay; showMenu;;
|
||||
13) commitsByMonth; showMenu;;
|
||||
14) commitsByWeekday; showMenu;;
|
||||
15) commitsByHour; showMenu;;
|
||||
16) author=""
|
||||
while [[ -z "${author}" ]]; do
|
||||
read -r -p "Which author? " author
|
||||
done
|
||||
commitsByHour "${author}"; showMenu;;
|
||||
16) suggestReviewers; showMenu;;
|
||||
17) suggestReviewers; showMenu;;
|
||||
q|"\n") exit;;
|
||||
*) clear; optionPicked "Pick an option from the menu"; showMenu;;
|
||||
esac
|
||||
|
||||
@@ -34,6 +34,11 @@ give a detailed list of git stats
|
||||
see detailed list of git stats by branch
|
||||
.HP
|
||||
.PP
|
||||
\fB\-V\fR, \fB\-\-csv\-output\-by\-branch\fR
|
||||
.IP
|
||||
output daily stats by branch in CSV format
|
||||
.HP
|
||||
.PP
|
||||
\fB\-d\fR, \fB\-\-commits\-per\-day\fR
|
||||
.IP
|
||||
displays a list of commits per day
|
||||
|
||||
@@ -26,6 +26,8 @@ OPTIONS
|
||||
give a detailed list of git stats
|
||||
-R, --git-stats-by-branch
|
||||
see detailed list of git stats by branch
|
||||
-V, --csv-output-by-branch
|
||||
output daily stats by branch in CSV format
|
||||
-d, --commits-per-day
|
||||
displays a list of commits per day
|
||||
-m, --commits-by-month
|
||||
|
||||
Reference in New Issue
Block a user