Compare commits

...

22 Commits

Author SHA1 Message Date
arzzen
125eec7136 Merge pull request #195 from tomice/issues/194-flatten-awk-arrays-for-bsd-awk-compat
Flatten arrays for wider awk compatibility
2025-09-02 11:46:39 +02:00
Tom Ice
d61c812247 Flatten arrays for wider awk compatibility
* The current implementation of the calendar heatmap by author
  contains multidimensional arrays. This works with newer versions
  of awk, but can cause issues with systems that use an older variant
  which cannot easily handle these calculations. macOS is especially
  impacted by this.

  By flattening the arrays from a multidimensional array to a single
  dimensional array, we can maintain greater compatibility across awk
  variants without requiring the user to install additional versions
  of awk.

Addresses issue #194
2025-08-31 16:22:59 -04:00
arzzen
261262ab4e Update Dockerfile - add coreutils 2025-08-03 18:48:37 +02:00
arzzen
e968ef62b9 Merge pull request #190 from git-quick-stats/task/commits-heatmap
commits heatmap
2025-06-29 08:57:05 +02:00
arzzen
74261c1e50 smallfixes 2025-06-29 08:55:49 +02:00
arzzen
4eade09673 Merge branch 'task/commits-heatmap' of github.com:git-quick-stats/git-quick-stats into task/commits-heatmap 2025-06-28 22:25:09 +02:00
arzzen
47a9151886 fix: tput colors, local vars 2025-06-28 22:24:51 +02:00
arzzen
916d5e1e0f Merge branch 'master' of github.com:git-quick-stats/git-quick-stats into task/commits-heatmap 2025-06-25 17:50:40 +02:00
arzzen
17a9d1427b Update git-quick-stats 2025-06-22 20:06:31 +02:00
arzzen
091562d4f8 Merge pull request #191 from git-quick-stats/task/citation-file
citation file
2025-06-22 20:03:57 +02:00
arzzen
748576b541 citation file 2025-06-22 20:03:38 +02:00
arzzen
f43ab22172 remove sponsors 2025-06-22 19:51:06 +02:00
arzzen
4d2e52aa6d commits heatmap 2025-06-22 19:49:49 +02:00
arzzen
08c0ca1d85 Update README.md 2025-06-17 19:24:24 +02:00
arzzen
e8843da10e Merge pull request #189 from git-quick-stats/134-feature-request-sorting-contribution-stats
Sorting contribution stats
2025-06-17 19:03:55 +02:00
arzzen
376887a394 update manpage 2025-06-17 19:01:38 +02:00
arzzen
cebb5a8f48 Merge pull request #188 from git-quick-stats/task/issue-116
_MENU_THEME=none
2025-06-17 18:52:01 +02:00
arzzen
95136d3f92 add filter ignored authors 2025-06-16 14:40:49 +02:00
arzzen
79c735c814 fix backslash 2025-06-16 14:36:11 +02:00
arzzen
ec6a95d2ef cleanup 2025-06-16 14:33:03 +02:00
arzzen
b65b100cd8 fix tests 2025-06-16 14:29:24 +02:00
arzzen
dd7719c3b0 sorting contribution stats 2025-06-16 14:03:21 +02:00
6 changed files with 1075 additions and 840 deletions

25
CITATION.cff Normal file
View File

@@ -0,0 +1,25 @@
cff-version: 1.2.0
title: Git Quick Stats
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- name-particle: tomice
- name-particle: arzzen
identifiers:
- type: url
value: "https://github.com/git-quick-stats"
description: >-
Simple and efficient way to access various statistics
in a git repository
repository-code: "https://github.com/git-quick-stats/git-quick-stats"
url: "https://git-quick-stats.sh/"
abstract: >-
Git-quick-stats is a simple and efficient way to access
various statistics in a git repository.
keywords:
- git
- stats
license: MIT
version: 2.6.2

View File

@@ -4,7 +4,7 @@ FROM alpine
COPY . /app COPY . /app
# Install required packages & build git-quick-stats # Install required packages & build git-quick-stats
RUN apk add --no-cache bash git make ncurses util-linux \ RUN apk add --no-cache bash git make ncurses coreutils util-linux \
&& cd /app \ && cd /app \
&& make install \ && make install \
&& rm -rf /app \ && rm -rf /app \

817
README.md
View File

@@ -1,406 +1,411 @@
# GIT quick statistics [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](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) # GIT quick statistics [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](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)
[![Homebrew package](https://repology.org/badge/version-for-repo/homebrew/git-quick-stats.svg)](https://formulae.brew.sh/formula/git-quick-stats#default) [![Homebrew package](https://repology.org/badge/version-for-repo/homebrew/git-quick-stats.svg)](https://formulae.brew.sh/formula/git-quick-stats#default)
> `git-quick-stats` is a simple and efficient way to access various statistics in a git repository. > `git-quick-stats` is a simple and efficient way to access various statistics in a git repository.
> >
> 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 :). > 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 :).
![mainMenuScreenshot](https://github.com/user-attachments/assets/05a20ff1-44f6-4e44-9d62-c2c089f9ff4e) ![mainImageScreenshot](https://github.com/user-attachments/assets/7d8637a4-5a67-49f6-8724-ca7548b987c6)
## Table of Contents ## Table of Contents
[**Screenshots**](#screenshots) [**Screenshots**](#screenshots)
[**Usage**](#usage) [**Usage**](#usage)
- [**Interactive**](#interactive) - [**Interactive**](#interactive)
- [**Non-interactive**](#non-interactive) - [**Non-interactive**](#non-interactive)
- [**Command-line arguments**](#command-line-arguments) - [**Command-line arguments**](#command-line-arguments)
- [**Git log since and until**](#git-log-since-and-until) - [**Git log since and until**](#git-log-since-and-until)
- [**Git log limit**](#git-log-limit) - [**Git log limit**](#git-log-limit)
- [**Git log options**](#git-log-options) - [**Git log options**](#git-log-options)
- [**Git pathspec**](#git-pathspec) - [**Git pathspec**](#git-pathspec)
- [**Git merge view strategy**](#git-merge-view-strategy) - [**Git merge view strategy**](#git-merge-view-strategy)
- [**Color themes**](#color-themes) - [**Color themes**](#color-themes)
[**Installation**](#installation) [**Installation**](#installation)
- [**UNIX and Linux**](#unix-and-linux) - [**UNIX and Linux**](#unix-and-linux)
- [**macOS**](#macos-homebrew) - [**macOS**](#macos-homebrew)
- [**Windows**](#windows) - [**Windows**](#windows)
- [**Docker**](#docker) - [**Docker**](#docker)
[**System requirements**](#system-requirements) [**System requirements**](#system-requirements)
- [**Dependencies**](#dependencies) - [**Dependencies**](#dependencies)
[**FAQ**](#faq) [**FAQ**](#faq)
[**Contribution**](#contribution) [**Contribution**](#contribution)
- [**Code reviews**](#code-reviews) - [**Code reviews**](#code-reviews)
- [**Some tips for good pull requests**](#some-tips-for-good-pull-requests) - [**Some tips for good pull requests**](#some-tips-for-good-pull-requests)
- [**Formatting**](#formatting) - [**Formatting**](#formatting)
[**Tests**](#tests) [**Tests**](#tests)
[**Licensing**](#licensing) [**Licensing**](#licensing)
[**Contributors**](#contributors) [**Contributors**](#contributors)
- [**Backers**](#backers) - [**Backers**](#backers)
- [**Sponsors**](#sponsors) - [**Sponsors**](#sponsors)
## Screenshots ## Screenshots
![commitsByWeekdayScreenshot](https://github.com/user-attachments/assets/3a55f3ac-8801-4bbf-9b3a-92b53a64631e) ![commitsByWeekdayScreenshot](https://github.com/user-attachments/assets/3496d245-6385-47d1-878a-726e79100eb1)
![commitsByHourScreenshot](https://github.com/user-attachments/assets/d7de5280-8bb9-4391-9c6c-7e688f2df171) ![commitsByHourScreenshot](https://github.com/user-attachments/assets/9f1d69d9-46e0-411d-a5ed-905ffdfb887a)
## Usage ![commitActivityScreenshot](https://github.com/user-attachments/assets/693fff31-65c7-4b9f-a011-6114a2d10a26)
### Interactive ## Usage
`git-quick-stats` has a built-in interactive menu that can be executed as such: ### Interactive
```bash `git-quick-stats` has a built-in interactive menu that can be executed as such:
git-quick-stats
``` ```bash
git-quick-stats
Or ```
```bash Or
git quick-stats
``` ```bash
git quick-stats
### Non-interactive ```
For those who prefer to utilize command-line options, `git-quick-stats` also has a non-interactive mode supporting both short and long options: ### Non-interactive
```bash For those who prefer to utilize command-line options, `git-quick-stats` also has a non-interactive mode supporting both short and long options:
git-quick-stats <optional-command-to-execute-directly>
``` ```bash
git-quick-stats <optional-command-to-execute-directly>
Or ```
```bash Or
git quick-stats <optional-command-to-execute-directly>
``` ```bash
git quick-stats <optional-command-to-execute-directly>
### Command-line arguments ```
Possible arguments in short and long form: ### Command-line arguments
```bash Possible arguments in short and long form:
GENERATE OPTIONS
-T, --detailed-git-stats ```bash
give a detailed list of git stats GENERATE OPTIONS
-R, --git-stats-by-branch -T, --detailed-git-stats
see detailed list of git stats by branch give a detailed list of git stats
-c, --changelogs -R, --git-stats-by-branch
see changelogs see detailed list of git stats by branch
-L, --changelogs-by-author -c, --changelogs
see changelogs by author see changelogs
-S, --my-daily-stats -L, --changelogs-by-author
see your current daily stats see changelogs by author
-V, --csv-output-by-branch -S, --my-daily-stats
output daily stats by branch in CSV format see your current daily stats
-j, --json-output -V, --csv-output-by-branch
save git log as a JSON formatted file to a specified area output daily stats by branch in CSV format
-j, --json-output
LIST OPTIONS save git log as a JSON formatted file to a specified area
-b, --branch-tree
show an ASCII graph of the git repo branch history LIST OPTIONS
-D, --branches-by-date -b, --branch-tree
show branches by date show an ASCII graph of the git repo branch history
-C, --contributors -D, --branches-by-date
see a list of everyone who contributed to the repo show branches by date
-n, --new-contributors -C, --contributors
list everyone who made their first contribution since a specified date see a list of everyone who contributed to the repo
-a, --commits-per-author -n, --new-contributors
displays a list of commits per author list everyone who made their first contribution since a specified date
-d, --commits-per-day -a, --commits-per-author
displays a list of commits per day displays a list of commits per author
-Y, --commits-by-year -d, --commits-per-day
displays a list of commits per year displays a list of commits per day
-m, --commits-by-month -m, --commits-by-month
displays a list of commits per month displays a list of commits per month
-w, --commits-by-weekday -Y, --commits-by-year
displays a list of commits per weekday displays a list of commits per year
-W, --commits-by-author-by-weekday -w, --commits-by-weekday
displays a list of commits per weekday by author displays a list of commits per weekday
-o, --commits-by-hour -W, --commits-by-author-by-weekday
displays a list of commits per hour displays a list of commits per weekday by author
-A, --commits-by-author-by-hour -o, --commits-by-hour
displays a list of commits per hour by author displays a list of commits per hour
-z, --commits-by-timezone -A, --commits-by-author-by-hour
displays a list of commits per timezone displays a list of commits per hour by author
-Z, --commits-by-author-by-timezone -z, --commits-by-timezone
displays a list of commits per timezone by author displays a list of commits per timezone
-Z, --commits-by-author-by-timezone
SUGGEST OPTIONS displays a list of commits per timezone by author
-r, --suggest-reviewers
show the best people to contact to review code CALENDAR OPTIONS
-h, -?, --help -k, --commits-calendar-by-author
display this help text in the terminal shows a calendar heatmap of commits per day-of-week per month for a given author
``` -H, --commits-heatmap
shows a heatmap of commits per day-of-week per month for the last 30 days
### Git log since and until
SUGGEST OPTIONS
You can set the variables `_GIT_SINCE` and/or `_GIT_UNTIL` before running `git-quick-stats` to limit the git log. These work similar to git's built-in `--since` and `--until` log options. -r, --suggest-reviewers
show the best people to contact to review code
```bash -h, -?, --help
export _GIT_SINCE="2017-01-20" display this help text in the terminal
export _GIT_UNTIL="2017-01-22" ```
```
### Git log since and until
Once set, run `git quick-stats` as normal. Note that this affects all stats that parse the git log history until unset.
You can set the variables `_GIT_SINCE` and/or `_GIT_UNTIL` before running `git-quick-stats` to limit the git log. These work similar to git's built-in `--since` and `--until` log options.
### Git log limit
```bash
You can set variable `_GIT_LIMIT` for limited output. It will affect the "changelogs" and "branch tree" options. The default limit is `10`. export _GIT_SINCE="2017-01-20"
export _GIT_UNTIL="2017-01-22"
```bash ```
export _GIT_LIMIT=20
``` Once set, run `git quick-stats` as normal. Note that this affects all stats that parse the git log history until unset.
### Git log options ### Git log limit
You can set `_GIT_LOG_OPTIONS` for [git log options](https://git-scm.com/docs/git-log#_options): You can set variable `_GIT_LIMIT` for limited output. It will affect the "changelogs" and "branch tree" options. The default limit is `10`.
```bash ```bash
export _GIT_LOG_OPTIONS="--ignore-all-space --ignore-blank-lines" export _GIT_LIMIT=20
``` ```
### Git pathspec ### Git log options
You can exclude a directory from the stats by using [pathspec](https://git-scm.com/docs/gitglossary#gitglossary-aiddefpathspecapathspec) You can set `_GIT_LOG_OPTIONS` for [git log options](https://git-scm.com/docs/git-log#_options):
```bash ```bash
export _GIT_PATHSPEC=':!directory' export _GIT_LOG_OPTIONS="--ignore-all-space --ignore-blank-lines"
``` ```
You can also exclude files from the stats. Note that it works with any alphanumeric, glob, or regex that git respects. ### Git pathspec
```bash You can exclude a directory from the stats by using [pathspec](https://git-scm.com/docs/gitglossary#gitglossary-aiddefpathspecapathspec)
export _GIT_PATHSPEC=':!package-lock.json'
``` ```bash
export _GIT_PATHSPEC=':!directory'
### Git merge view strategy ```
You can set the variable `_GIT_MERGE_VIEW` to enable merge commits to be part of the stats by setting `_GIT_MERGE_VIEW` to `enable`. You can also choose to only show merge commits by setting `_GIT_MERGE_VIEW` to `exclusive`. Default is to not show merge commits. These work similar to git's built-in `--merges` and `--no-merges` log options. You can also exclude files from the stats. Note that it works with any alphanumeric, glob, or regex that git respects.
```bash ```bash
export _GIT_MERGE_VIEW="enable" export _GIT_PATHSPEC=':!package-lock.json'
export _GIT_MERGE_VIEW="exclusive" ```
```
### Git merge view strategy
### Git branch
You can set the variable `_GIT_MERGE_VIEW` to enable merge commits to be part of the stats by setting `_GIT_MERGE_VIEW` to `enable`. You can also choose to only show merge commits by setting `_GIT_MERGE_VIEW` to `exclusive`. Default is to not show merge commits. These work similar to git's built-in `--merges` and `--no-merges` log options.
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
```bash export _GIT_MERGE_VIEW="enable"
export _GIT_BRANCH="master" export _GIT_MERGE_VIEW="exclusive"
``` ```
You can set the variable `_GIT_IGNORE_AUTHORS` to filter out specific authors. It will affect the "All contributors", ""Suggested code reviewers" and "New contributors" options. ### Git branch
```bash 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`.
export _GIT_IGNORE_AUTHORS="(author@examle.com|username)"
``` ```bash
export _GIT_BRANCH="master"
### Color themes ```
You can change to the legacy color scheme by toggling the variable `_MENU_THEME` between `default` and `legacy`. ### Ignore authors
You can completely disable the color theme by setting the `_MENU_THEME` variable to `none`.
You can set the variable `_GIT_IGNORE_AUTHORS` to filter out specific authors. It will affect the "All contributors", ""Suggested code reviewers" and "New contributors" options.
```bash
export _MENU_THEME="legacy" ```bash
# or export _GIT_IGNORE_AUTHORS="(author@examle.com|username)"
export _MENU_THEME="none" ```
```
### Sorting contribution stats
![legacyThemeScreenshot](https://github.com/user-attachments/assets/3b319c1a-827f-47b8-bbfa-b8b59a39deef)
You can sort contribution stats by field `name`, `commits`, `insertions`, `deletions`, or `lines` (total lines changed) and order (`asc`, `desc`). e.g.: `commits-desc`
## Installation
```bash
### Debian and Ubuntu export _GIT_SORT_BY="name-asc"
```
If you are on at least Debian Bullseye or Ubuntu Focal you can use apt for installation:
### Commit days
```bash
apt install git-quick-stats You can set \_GIT_DAYS to set the number of days for the heatmap
```
```bash
### UNIX and Linux export _GIT_DAYS=30
```
```bash
git clone https://github.com/git-quick-stats/git-quick-stats.git && cd git-quick-stats ### Color themes
sudo make install
``` You can change to the legacy color scheme by toggling the variable `_MENU_THEME` between `default` and `legacy`.
You can completely disable the color theme by setting the `_MENU_THEME` variable to `none`.
For uninstalling, open up the cloned directory and run
```bash
```bash export _MENU_THEME="legacy"
sudo make uninstall # or
``` export _MENU_THEME="none"
```
For update/reinstall
![legacyThemeScreenshot](https://github.com/user-attachments/assets/3b319c1a-827f-47b8-bbfa-b8b59a39deef)
```bash
sudo make reinstall ## Installation
```
### Debian and Ubuntu
### macOS (homebrew)
If you are on at least Debian Bullseye or Ubuntu Focal you can use apt for installation:
macOS requires GNU coreutils to be installed and for the non "g" aliased
versions to be exported to your path. The following is an example of how to ```bash
perform this if you are using Homebrew as your package manager. apt install git-quick-stats
```
```bash
brew install coreutils ### UNIX and Linux
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
``` ```bash
git clone https://github.com/git-quick-stats/git-quick-stats.git && cd git-quick-stats
From there, you can install via Homebrew as follows: sudo make install
```
```bash
brew install git-quick-stats For uninstalling, open up the cloned directory and run
```
```bash
Or you can follow the UNIX and Linux instructions if you wish. sudo make uninstall
```
If you would like to default to using the GNU coreutils (recommended), then you
can add `export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"` to For update/reinstall
your applicable `~/.bash_profile`, `~/.zprofile`, or other relevant profile
based on the shell of your choice. ```bash
sudo make reinstall
### Windows ```
If you are installing with Cygwin, use these scripts: ### macOS (homebrew)
- [installer](https://gist.github.com/arzzen/35e09866dfdadf2108b2420045739245) macOS requires GNU coreutils to be installed and for the non "g" aliased
- [uninstaller](https://gist.github.com/arzzen/21c660014d0663b6c5710014714779d6) versions to be exported to your path. The following is an example of how to
perform this if you are using Homebrew as your package manager.
If you are wishing to use this with WSL, follow the UNIX and Linux instructions.
```bash
### Docker brew install coreutils
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
You can use the Docker image provided: ```
- Build: `docker build -t arzzen/git-quick-stats .` From there, you can install via Homebrew as follows:
- Run interactive menu: `docker run --rm -it -v $(pwd):/git arzzen/git-quick-stats`
- Docker pull command: `docker pull arzzen/git-quick-stats` [docker repository](https://hub.docker.com/r/arzzen/git-quick-stats) ```bash
brew install git-quick-stats
## System requirements ```
- An OS with a Bash shell Or you can follow the UNIX and Linux instructions if you wish.
- Tools we use:
If you would like to default to using the GNU coreutils (recommended), then you
```bash can add `export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"` to
awk your applicable `~/.bash_profile`, `~/.zprofile`, or other relevant profile
basename based on the shell of your choice.
cat
column ### Windows
date
echo If you are installing with Cygwin, use these scripts:
git
grep - [installer](https://gist.github.com/arzzen/35e09866dfdadf2108b2420045739245)
head - [uninstaller](https://gist.github.com/arzzen/21c660014d0663b6c5710014714779d6)
printf
seq If you are wishing to use this with WSL, follow the UNIX and Linux instructions.
sort
tput ### Docker
tr
uniq You can use the Docker image provided:
```
- Build: `docker build -t arzzen/git-quick-stats .`
### Dependencies - Run interactive menu: `docker run --rm -it -v $(pwd):/git arzzen/git-quick-stats`
- Docker pull command: `docker pull arzzen/git-quick-stats` [docker repository](https://hub.docker.com/r/arzzen/git-quick-stats)
- [`bsdextrautils`](https://packages.debian.org/sid/bsdextrautils) `apt install bsdextrautils`
- [`coreutils`](https://packages.debian.org/sid/coreutils) `apt install coreutils` ## System requirements
- [`gawk`](https://packages.debian.org/sid/gawk) `apt install gawk`
- [`grep`](https://packages.debian.org/sid/grep) `apt install grep` - An OS with a Bash shell
- [`ncurses-bin`](https://packages.debian.org/sid/ncurses-bin) `apt install ncurses-bin` - Tools we use:
## FAQ ```bash
awk
_Q:_ I get some errors after run git-quick-stats in cygwin like `/usr/local/bin/git-quick-stats: line 2: $'\r': command not found` basename
cat
_A:_ You can run the dos2unix app in cygwin as follows: `/bin/dos2unix.exe /usr/local/bin/git-quick-stats`. This will convert the script from the CR-LF convention that Microsoft uses to the LF convention that UNIX, OS X, and Linux use. You should then should be able to run it as normal. column
date
_Q:_ How they could be used in a project with many git projects and statistics would show a summary of all git projects? echo
git
_A:_ If you want to include submodule logs, you can try using the following: `export _GIT_LOG_OPTIONS="-p --submodule=log"` grep
(more info about [git log --submodule](https://git-scm.com/docs/git-log#Documentation/git-log.txt---submoduleltformatgt)) head
printf
## Contribution seq
sort
Want to contribute? Great! First, read this page. tput
tr
### Code reviews uniq
```
All submissions, including submissions by project members, require review.</br>
We use GitHub pull requests for this purpose. ### Dependencies
### Some tips for good pull requests - [`bsdextrautils`](https://packages.debian.org/sid/bsdextrautils) `apt install bsdextrautils`
- [`coreutils`](https://packages.debian.org/sid/coreutils) `apt install coreutils`
- Use our code </br> - [`gawk`](https://packages.debian.org/sid/gawk) `apt install gawk`
When in doubt, try to stay true to the existing code of the project. - [`grep`](https://packages.debian.org/sid/grep) `apt install grep`
- Write a descriptive commit message. What problem are you solving and what - [`ncurses-bin`](https://packages.debian.org/sid/ncurses-bin) `apt install ncurses-bin`
are the consequences? Where and what did you test? Some good tips:
[here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message) ## FAQ
and [here](https://www.kernel.org/doc/Documentation/SubmittingPatches).
- If your PR consists of multiple commits which are successive improvements / _Q:_ I get some errors after run git-quick-stats in cygwin like `/usr/local/bin/git-quick-stats: line 2: $'\r': command not found`
fixes to your first commit, consider squashing them into a single commit
(`git rebase -i`) such that your PR is a single commit on top of the current _A:_ You can run the dos2unix app in cygwin as follows: `/bin/dos2unix.exe /usr/local/bin/git-quick-stats`. This will convert the script from the CR-LF convention that Microsoft uses to the LF convention that UNIX, OS X, and Linux use. You should then should be able to run it as normal.
HEAD. This make reviewing the code so much easier, and our history more
readable. _Q:_ How they could be used in a project with many git projects and statistics would show a summary of all git projects?
### Formatting _A:_ If you want to include submodule logs, you can try using the following: `export _GIT_LOG_OPTIONS="-p --submodule=log"`
(more info about [git log --submodule](https://git-scm.com/docs/git-log#Documentation/git-log.txt---submoduleltformatgt))
This documentation is written using standard [markdown syntax](https://help.github.com/articles/markdown-basics/). Please submit your changes using the same syntax.
## Contribution
## Tests
Want to contribute? Great! First, read this page.
[![codecov](https://codecov.io/gh/arzzen/git-quick-stats/branch/master/graph/badge.svg)](https://codecov.io/gh/arzzen/git-quick-stats)
### Code reviews
```bash
make test All submissions, including submissions by project members, require review.</br>
``` We use GitHub pull requests for this purpose.
## Licensing ### Some tips for good pull requests
MIT see [LICENSE][] for the full license text. - Use our code </br>
When in doubt, try to stay true to the existing code of the project.
[read this page]: http://github.com/git-quick-stats/git-quick-stats/blob/master/.github/CONTRIBUTING.md - Write a descriptive commit message. What problem are you solving and what
[landing page]: https://git-quick-stats.sh are the consequences? Where and what did you test? Some good tips:
[LICENSE]: https://github.com/git-quick-stats/git-quick-stats/blob/master/LICENSE [here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)
and [here](https://www.kernel.org/doc/Documentation/SubmittingPatches).
## Contributors - If your PR consists of multiple commits which are successive improvements /
fixes to your first commit, consider squashing them into a single commit
This project exists thanks to all the people who contribute. (`git rebase -i`) such that your PR is a single commit on top of the current
HEAD. This make reviewing the code so much easier, and our history more
[![contributors](https://opencollective.com/git-quick-stats/contributors.svg?width=890&button=false)](https://github.com/git-quick-stats/git-quick-stats/graphs/contributors) readable.
### Backers ### Formatting
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/git-quick-stats#backer)] This documentation is written using standard [markdown syntax](https://help.github.com/articles/markdown-basics/). Please submit your changes using the same syntax.
[![backers](https://opencollective.com/git-quick-stats/backers.svg?width=890)](https://opencollective.com/git-quick-stats#backers) ## Tests
### Sponsors [![codecov](https://codecov.io/gh/arzzen/git-quick-stats/branch/master/graph/badge.svg)](https://codecov.io/gh/arzzen/git-quick-stats)
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/git-quick-stats#sponsor)] ```bash
make test
[![sponsor0](https://opencollective.com/git-quick-stats/sponsor/0/avatar.svg?v=1)](https://opencollective.com/git-quick-stats/sponsor/0/website) ```
[![sponsor1](https://opencollective.com/git-quick-stats/sponsor/1/avatar.svg)](https://opencollective.com/git-quick-stats/sponsor/1/website)
[![sponsor2](https://opencollective.com/git-quick-stats/sponsor/2/avatar.svg)](https://opencollective.com/git-quick-stats/sponsor/2/website) ## Licensing
[![sponsor3](https://opencollective.com/git-quick-stats/sponsor/3/avatar.svg)](https://opencollective.com/git-quick-stats/sponsor/3/website)
[![sponsor4](https://opencollective.com/git-quick-stats/sponsor/4/avatar.svg)](https://opencollective.com/git-quick-stats/sponsor/4/website) MIT see [LICENSE][] for the full license text.
[![sponsor5](https://opencollective.com/git-quick-stats/sponsor/5/avatar.svg)](https://opencollective.com/git-quick-stats/sponsor/5/website)
[![sponsor6](https://opencollective.com/git-quick-stats/sponsor/6/avatar.svg)](https://opencollective.com/git-quick-stats/sponsor/6/website) [read this page]: http://github.com/git-quick-stats/git-quick-stats/blob/master/.github/CONTRIBUTING.md
[![sponsor7](https://opencollective.com/git-quick-stats/sponsor/7/avatar.svg)](https://opencollective.com/git-quick-stats/sponsor/7/website) [landing page]: https://git-quick-stats.sh
[![sponsor8](https://opencollective.com/git-quick-stats/sponsor/8/avatar.svg)](https://opencollective.com/git-quick-stats/sponsor/8/website) [LICENSE]: https://github.com/git-quick-stats/git-quick-stats/blob/master/LICENSE
[![sponsor9](https://opencollective.com/git-quick-stats/sponsor/9/avatar.svg)](https://opencollective.com/git-quick-stats/sponsor/9/website)
## Contributors
This project exists thanks to all the people who contribute.
[![contributors](https://opencollective.com/git-quick-stats/contributors.svg?width=890&button=false)](https://github.com/git-quick-stats/git-quick-stats/graphs/contributors)

View File

@@ -10,6 +10,24 @@
set -o nounset set -o nounset
set -o errexit set -o errexit
# Global color variables using tput setaf
COLOR_NORMAL=$(tput sgr0)
COLOR_CYANL=$(tput setaf 6)
COLOR_BOLD=$(tput bold)
COLOR_RED=$(tput setaf 1)
COLOR_YELLOW=$(tput setaf 3)
COLOR_WHITE=$(tput setaf 7)
COLOR_BRIGHT_YELLOW=$(tput setaf 226)
COLOR_GOLD=$(tput setaf 220)
COLOR_ORANGE=$(tput setaf 214)
COLOR_DARK_ORANGE=$(tput setaf 208)
COLOR_RED_ORANGE=$(tput setaf 202)
COLOR_DARK_RED=$(tput setaf 160)
COLOR_DEEP_RED=$(tput setaf 88)
COLOR_DARKEST_RED=$(tput setaf 52)
COLOR_GRAY=$(tput setaf 240)
COLOR_RESET=$(tput sgr0)
# Beginning git log date. Respects all git datetime formats # Beginning git log date. Respects all git datetime formats
# If $_GIT_SINCE is never set, look at the repository to find the first date. # If $_GIT_SINCE is never set, look at the repository to find the first date.
# NOTE: previously this put the date at the fixed GIT epoch (May 2005) # NOTE: previously this put the date at the fixed GIT epoch (May 2005)
@@ -76,6 +94,22 @@ else
_ignore_authors="" _ignore_authors=""
fi fi
# Sort by field and order for contribution stats
_GIT_SORT_BY=${_GIT_SORT_BY:-name-asc}
# If the user has not set a sort order, default to name-asc
if [[ ! "$_GIT_SORT_BY" =~ ^(name|commits|insertions|deletions|lines)-(asc|desc)$ ]]; then
echo "Invalid sort option: $_GIT_SORT_BY. Defaulting to 'name-asc'."
_GIT_SORT_BY="name-asc"
fi
# Number of days to display in the heatmap
_commit_days=${_GIT_DAYS:-30}
# If the user has not set a number of days, default to 30
if ! [[ "$_commit_days" =~ ^[0-9]+$ ]] || (( _commit_days <= 0 )); then
echo "Invalid number of days: $_commit_days. Defaulting to 30."
_commit_days=30
fi
# Default menu theme # Default menu theme
# Set the legacy theme by typing "export _MENU_THEME=legacy" # Set the legacy theme by typing "export _MENU_THEME=legacy"
_theme="${_MENU_THEME:=default}" _theme="${_MENU_THEME:=default}"
@@ -96,40 +130,130 @@ function commitsCalendarByAuthor() {
--date=iso --author="$author" "$_since" "$_until" $_log_options \ --date=iso --author="$author" "$_since" "$_until" $_log_options \
--pretty='%ad' $_pathspec | awk ' --pretty='%ad' $_pathspec | awk '
{ {
split($0, a, " "); split($0, a, " ");
# a[1] = YYYY-MM-DD # a[1] = YYYY-MM-DD
split(a[1], date_fields, "-"); split(a[1], date_fields, "-");
mon = date_fields[2] + 0; mon = date_fields[2] + 0;
cmd = "date -d \"" a[1] "\" +%u"; cmd = "date -d \"" a[1] "\" +%u";
cmd | getline weekday; cmd | getline weekday;
close(cmd); close(cmd);
# weekday: 1=Mon, ..., 7=Sun # weekday: 1=Mon, ..., 7=Sun
count[weekday][mon]++; count[weekday * 12 + mon]++;
} }
END { END {
# Output matrix # Output matrix
for (d=1; d<=7; d++) { for (d=1; d<=7; d++) {
if (d==1) printf "Mon "; if (d==1) printf "Mon ";
else if (d==2) printf "Tue "; else if (d==2) printf "Tue ";
else if (d==3) printf "Wed "; else if (d==3) printf "Wed ";
else if (d==4) printf "Thu "; else if (d==4) printf "Thu ";
else if (d==5) printf "Fri "; else if (d==5) printf "Fri ";
else if (d==6) printf "Sat "; else if (d==6) printf "Sat ";
else if (d==7) printf "Sun "; else if (d==7) printf "Sun ";
for (m=1; m<=12; m++) { for (m=1; m<=12; m++) {
c = count[d][m]+0; c = count[d * 12 + m]+0;
if (c==0) out="..."; if (c==0)
else if (c<=9) out="░░░"; out="...";
else if (c<=19) out="▒▒▒"; else if (c<=9)
else out="▓▓▓"; out="░░░";
printf "%s%s", out, (m<12?" ":"\n"); else if (c<=19)
} out="▒▒▒";
else
out="▓▓▓";
printf "%s%s", out, (m<12?" ":"\n"); }
} }
printf "\nLegend: ... = 0 ░░░ = 19 ▒▒▒ = 1019 ▓▓▓ = 20+ commits\n"; printf "\nLegend: ... = 0 ░░░ = 19 ▒▒▒ = 1019 ▓▓▓ = 20+ commits\n";
} }
' '
} }
# DESC: Shows a heatmap of commits per hour of each day for the last 30 days
function commitsHeatmap() {
optionPicked "Commit Heatmap for the last $_commit_days days"
color_for_count() {
local n=$1
if (( n == 1 )); then
echo -n "${COLOR_BRIGHT_YELLOW}"
elif (( n < 2 )); then
echo -n "${COLOR_GOLD}"
elif (( n < 3 )); then
echo -n "${COLOR_ORANGE}"
elif (( n < 4 )); then
echo -n "${COLOR_DARK_ORANGE}"
elif (( n < 5 )); then
echo -n "${COLOR_RED_ORANGE}"
elif (( n < 6 )); then
echo -n "${COLOR_RED}"
elif (( n < 8 )); then
echo -n "${COLOR_DARK_RED}"
elif (( n < 10 )); then
echo -n "${COLOR_DEEP_RED}"
else
echo -n "${COLOR_DARKEST_RED}"
fi
}
printf "Day | Date/Hours |"
local h
for h in {0..23}; do
printf " %2d" "$h"
done
echo
echo "------------------------------------------------------------------------------------------"
local i
for i in $(seq $((_commit_days-1)) -1 0); do
local day=$(date -d "-$i days" +"%Y-%m-%d")
if [[ $(date -d "$day" +%u) -gt 5 ]]; then
echo -en "${COLOR_GRAY}"
else
echo -en "${COLOR_RESET}"
fi
local dayName=$(date -d "$day" +%a)
printf "%s | %s |" "$dayName" "$day"
declare -a commits_per_hour
local h
for h in {0..23}; do
commits_per_hour[$h]=0
done
IFS=$'\n' commits_per_hour=($(
git log --since="$day 00:00" --until="$day 23:59" --pretty=format:"%ci" 2>/dev/null |
awk '{split($2, t, ":"); h = t[1]+0; c[h]++} END {for(i=0;i<24;i++) print c[i]+0}'
))
unset IFS
local h
for h in {0..23}; do
local count=${commits_per_hour[$h]}
local color=$(color_for_count "$count")
if (( count == 0 )); then
echo -en " ${COLOR_GRAY}.${COLOR_RESET} "
else
echo -en "${color} █ ${COLOR_RESET}"
fi
done
echo
done
echo "------------------------------------------------------------------------------------------"
echo -e "\nLegend:"
echo -e " ${COLOR_BRIGHT_YELLOW}█${COLOR_RESET} 1 commit"
echo -e " ${COLOR_GOLD}█${COLOR_RESET} 2 commits"
echo -e " ${COLOR_ORANGE}█${COLOR_RESET} 3 commits"
echo -e " ${COLOR_DARK_ORANGE}█${COLOR_RESET} 4 commits"
echo -e " ${COLOR_RED_ORANGE}█${COLOR_RESET} 5 commits"
echo -e " ${COLOR_RED}█${COLOR_RESET} 6 commits"
echo -e " ${COLOR_DARK_RED}█${COLOR_RESET} 78 commits"
echo -e " ${COLOR_DEEP_RED}█${COLOR_RESET} 910 commits"
echo -e " ${COLOR_DARKEST_RED}█${COLOR_RESET} 11+ commits"
echo -e " ${COLOR_GRAY}.${COLOR_RESET} = no commits"
echo
}
################################################################################ ################################################################################
# HELPER AND MENU FUNCTIONS # HELPER AND MENU FUNCTIONS
@@ -196,7 +320,7 @@ DESCRIPTION
Any git repository contains tons of information about commits, contributors, Any git repository contains tons of information about commits, contributors,
and files. Extracting this information is not always trivial, mostly because and files. Extracting this information is not always trivial, mostly because
of a gadzillion options to a gadzillion git commands. of a gadzillion options to a gadzillion git commands.
This program allows you to see detailed information about a git repository. This program allows you to see detailed information about a git repository.
GENERATE OPTIONS GENERATE OPTIONS
@@ -245,6 +369,12 @@ LIST OPTIONS
-Z, --commits-by-author-by-timezone -Z, --commits-by-author-by-timezone
displays a list of commits per timezone by author displays a list of commits per timezone by author
CALENDAR OPTIONS
-k, --commits-calendar-by-author
shows a calendar heatmap of commits per day-of-week per month for a given author
-H, --commits-heatmap
shows a heatmap of commits per day-of-week per month for the last 30 days
SUGGEST OPTIONS SUGGEST OPTIONS
-r, --suggest-reviewers -r, --suggest-reviewers
show the best people to contact to review code show the best people to contact to review code
@@ -270,7 +400,11 @@ ADDITIONAL USAGE
You can set _GIT_BRANCH to set the branch of the stats You can set _GIT_BRANCH to set the branch of the stats
ex: export _GIT_BRANCH=master ex: export _GIT_BRANCH=master
You can set _GIT_IGNORE_AUTHORS to filter out specific authors You can set _GIT_IGNORE_AUTHORS to filter out specific authors
ex: export _GIT_IGNORE_AUTHORS=\"(author1|author2)\"" ex: export _GIT_IGNORE_AUTHORS=\"(author1|author2)\"
You can sort contribution stats by field \"name\", \"commits\", \"insertions\", \"deletions\", or \"lines\" - total lines changed and order - \"asc\", \"desc\"
ex: export _GIT_SORT_BY=\"name-asc\"
You can set _GIT_DAYS to set the number of days for the heatmap
ex: export _GIT_DAYS=30"
} }
################################################################################ ################################################################################
@@ -280,12 +414,6 @@ ADDITIONAL USAGE
################################################################################ ################################################################################
function showMenu() { function showMenu() {
# These are "global" and can be overriden from users if so desired # These are "global" and can be overriden from users if so desired
NORMAL=$(tput sgr0)
CYAN=$(tput setaf 6)
BOLD=$(tput bold)
RED=$(tput setaf 1)
YELLOW=$(tput setaf 3)
WHITE=$(tput setaf 7)
TITLES="" TITLES=""
TEXT="" TEXT=""
NUMS="" NUMS=""
@@ -295,29 +423,29 @@ function showMenu() {
# Adjustable color menu option # Adjustable color menu option
case "${_theme}" in case "${_theme}" in
"legacy" ) "legacy" )
TITLES="${BOLD}${RED}" TITLES="${COLOR_BOLD}${COLOR_RED}"
TEXT="${NORMAL}${CYAN}" TEXT="${COLOR_NORMAL}${COLOR_CYANL}"
NUMS="${BOLD}${YELLOW}" NUMS="${COLOR_BOLD}${COLOR_YELLOW}"
HELP_TXT="${NORMAL}${YELLOW}" HELP_TXT="${COLOR_NORMAL}${COLOR_YELLOW}"
EXIT_TXT="${BOLD}${RED}" EXIT_TXT="${COLOR_BOLD}${COLOR_RED}"
;; ;;
"none" ) "none" )
TITLES="${BOLD}" TITLES="${COLOR_BOLD}"
TEXT="${NORMAL}" TEXT="${COLOR_NORMAL}"
NUMS="${BOLD}" NUMS="${COLOR_BOLD}"
HELP_TXT="${NORMAL}" HELP_TXT="${COLOR_NORMAL}"
EXIT_TXT="${BOLD}" EXIT_TXT="${COLOR_BOLD}"
;; ;;
*) *)
TITLES="${BOLD}${CYAN}" TITLES="${COLOR_BOLD}${COLOR_CYANL}"
TEXT="${NORMAL}${WHITE}" TEXT="${COLOR_NORMAL}${COLOR_WHITE}"
NUMS="${NORMAL}${BOLD}${WHITE}" NUMS="${COLOR_NORMAL}${COLOR_BOLD}${COLOR_WHITE}"
HELP_TXT="${NORMAL}${CYAN}" HELP_TXT="${COLOR_NORMAL}${COLOR_CYANL}"
EXIT_TXT="${BOLD}${CYAN}" EXIT_TXT="${COLOR_BOLD}${COLOR_CYANL}"
;; ;;
esac esac
printf %b "\\n${TITLES} Generate:${NORMAL}\\n" printf %b "\\n${TITLES} Generate:${COLOR_NORMAL}\\n"
printf %b "${NUMS} 1)${TEXT} Contribution stats (by author)\\n" printf %b "${NUMS} 1)${TEXT} Contribution stats (by author)\\n"
printf %b "${NUMS} 2)${TEXT} Contribution stats (by author) on a specific branch\\n" printf %b "${NUMS} 2)${TEXT} Contribution stats (by author) on a specific branch\\n"
printf %b "${NUMS} 3)${TEXT} Git changelogs (last $_limit days)\\n" printf %b "${NUMS} 3)${TEXT} Git changelogs (last $_limit days)\\n"
@@ -344,8 +472,9 @@ function showMenu() {
printf %b "${NUMS} 22)${TEXT} Code reviewers (based on git history)\\n" printf %b "${NUMS} 22)${TEXT} Code reviewers (based on git history)\\n"
printf %b "\\n${TITLES} Calendar:\\n" printf %b "\\n${TITLES} Calendar:\\n"
printf %b "${NUMS} 23)${TEXT} Activity calendar by author\\n" printf %b "${NUMS} 23)${TEXT} Activity calendar by author\\n"
printf %b "${NUMS} 24)${TEXT} Activity heatmap for the last $_commit_days days\\n"
printf %b "\\n${HELP_TXT}Please enter a menu option or ${EXIT_TXT}press Enter to exit.\\n" printf %b "\\n${HELP_TXT}Please enter a menu option or ${EXIT_TXT}press Enter to exit.\\n"
printf %b "${TEXT}> ${NORMAL}" printf %b "${TEXT}> ${COLOR_NORMAL}"
read -r opt read -r opt
} }
@@ -362,7 +491,7 @@ filter_ignored_authors() {
################################################################################ ################################################################################
# DESC: Shows detailed contribution stats per author by parsing every commit in # DESC: Shows detailed contribution stats per author by parsing every commit in
# the repo and outputting their contribution stats # the repo and outputting their contribution stats.
# ARGS: $branch (optional): Users can specify an alternative branch instead of # ARGS: $branch (optional): Users can specify an alternative branch instead of
# the current default one # the current default one
# OUTS: None # OUTS: None
@@ -394,82 +523,151 @@ function detailedGitStats() {
optionPicked "Contribution stats (by author) on the current branch:" optionPicked "Contribution stats (by author) on the current branch:"
fi fi
local sort_by="${_GIT_SORT_BY:-name-asc}"
local sort_field
local sort_order
local sort_command
sort_field=$(echo "$sort_by" | awk -F- '{print $1}')
sort_order=$(echo "$sort_by" | awk -F- '{print $2}')
local sort_key
case "$sort_field" in
name) sort_key=1 ;;
commits) sort_key=2 ;;
insertions) sort_key=3 ;;
deletions) sort_key=4 ;;
lines) sort_key=5 ;;
*)
echo "Invalid sort field: $sort_field. Defaulting to 'name'."
sort_key=1
;;
esac
echo -e "Sorting by: $sort_field ($sort_order)\n"
local sort_flags="-t'|' -k${sort_key},${sort_key}"
if [[ "$sort_field" != "name" ]]; then
sort_flags="${sort_flags}n"
fi
if [[ "$sort_order" == "desc" ]]; then
sort_flags="${sort_flags}r"
fi
sort_command="sort ${sort_flags}"
# 1. git log -> awk (extract data) -> sort -> awk (format output with graphs)
git -c log.showSignature=false log ${_branch} --use-mailmap $_merges --numstat \ 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" \ --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 ' "$_since" "$_until" $_log_options $_pathspec |
function printStats(author) { LC_ALL=C awk '
printf "\t%s:\n", author # This first awk script extracts raw data into a delimited format
if(more["total"] > 0) {
printf "\t insertions: %d\t(%.0f%%)\n", more[author], \
(more[author] / more["total"] * 100)
} else {
printf "\t insertions: %d\t(%.0f%%)\n", 0, 0
}
if(less["total"] > 0) {
printf "\t deletions: %d\t(%.0f%%)\n", less[author], \
(less[author] / less["total"] * 100)
} else {
printf "\t deletions: %d\t(%.0f%%)\n", 0, 0
}
if(file["total"] > 0) {
printf "\t files: %d\t(%.0f%%)\n", file[author], \
(file[author] / file["total"] * 100)
}
if(commits["total"] > 0) {
printf "\t commits: %d\t(%.0f%%)\n", commits[author], \
(commits[author] / commits["total"] * 100)
}
if (first[author] != "") {
if ( ((more["total"] + less["total"]) * 100) > 0) {
printf "\t lines changed: %d\t", more[author] + less[author]
printf "(%.0f%%)\n", ((more[author] + less[author]) / \
(more["total"] + less["total"]) * 100)
}
else {
printf "\t lines changed: %d\t(0%%)\n", (more[author] + less[author])
}
printf "\t first commit: %s\n", first[author]
printf "\t last commit: %s\n", last[author]
}
printf "\n"
}
/^Author:/ { /^Author:/ {
$1 = "" $1 = ""; author = $0;
author = $0 commits[author] += 1;
commits[author] += 1
commits["total"] += 1
} }
/^Date:/ { /^Date:/ {
$1=""; $1=""; current_date = substr($0, 2);
first[author] = substr($0, 2) if (last[author] == "") { last[author] = current_date; }
if(last[author] == "" ) { last[author] = first[author] } first[author] = current_date;
} }
/^[0-9]/ { /^[0-9]/ {
more[author] += $1 more[author] += $1;
less[author] += $2 less[author] += $2;
file[author] += 1;
file[author] += 1
more["total"] += $1
less["total"] += $2
file["total"] += 1
} }
END { END {
for (author in commits) { for (author in commits) {
if (author != "total") { lines_changed = more[author] + less[author];
printStats(author) printf "%s|%d|%d|%d|%d|%d|%s|%s\n",
author, commits[author]+0, more[author]+0, less[author]+0,
lines_changed, file[author]+0, first[author], last[author];
} }
}' |
eval "$sort_command" | filter_ignored_authors |
LC_ALL=C awk '
# This second awk script stores data, calculates totals, and then formats output with graphs
BEGIN {
FS = "|";
total_commits = 0; total_insertions = 0; total_deletions = 0;
total_lines = 0; total_files = 0;
num_authors = 0; # Counter for stored authors
} }
printStats("total") {
# Store all data for a second pass after totals are known
authors[num_authors] = $1;
commits_arr[num_authors] = $2;
insertions_arr[num_authors] = $3;
deletions_arr[num_authors] = $4;
lines_changed_arr[num_authors] = $5;
files_arr[num_authors] = $6;
first_commit_arr[num_authors] = $7;
last_commit_arr[num_authors] = $8;
# Accumulate overall totals
total_commits += $2;
total_insertions += $3;
total_deletions += $4;
total_lines += $5;
total_files += $6;
num_authors++;
}
END {
for (j = 0; j < num_authors; j++) {
author = authors[j];
current_commits = commits_arr[j];
current_insertions = insertions_arr[j];
current_deletions = deletions_arr[j];
current_lines_changed = lines_changed_arr[j];
current_files = files_arr[j];
current_first_commit = first_commit_arr[j];
current_last_commit = last_commit_arr[j];
printf "\t%s:\n", author;
# Commits graph
if (total_commits > 0) {
commit_percent = (current_commits * 100.0) / total_commits;
printf "\t commits: %d (%.1f%%)\n", current_commits, commit_percent;
} else {
printf "\t commits: %d\n", current_commits;
}
# Insertions graph
if (total_insertions > 0) {
insert_percent = (current_insertions * 100.0) / total_insertions;
printf "\t insertions: %d (%.1f%%)\n", current_insertions, insert_percent;
} else {
printf "\t insertions: %d\n", current_insertions;
}
# Deletions graph
if (total_deletions > 0) {
delete_percent = (current_deletions * 100.0) / total_deletions;
printf "\t deletions: %d (%.1f%%)\n", current_deletions, delete_percent;
} else {
printf "\t deletions: %d\n", current_deletions;
}
# Lines changed graph
if (total_lines > 0) {
lines_percent = (current_lines_changed * 100.0) / total_lines;
printf "\t lines changed: %d (%.1f%%)\n", current_lines_changed, lines_percent;
} else {
printf "\t lines changed: %d\n", current_lines_changed;
}
printf "\t files: %d\n", current_files;
printf "\t first commit: %s\n", current_first_commit;
printf "\t last commit: %s\n\n", current_last_commit;
}
# Print overall totals
printf "\t%s:\n", " total";
printf "\t commits: %d\n", total_commits;
printf "\t insertions: %d\n", total_insertions;
printf "\t deletions: %d\n", total_deletions;
printf "\t lines changed: %d\n", total_lines;
printf "\t files: %d\n\n", total_files;
}' }'
} }
@@ -554,9 +752,10 @@ function csvOutput() {
local _branch="" local _branch=""
# Check if requesting for a specific branch # Check if requesting for a specific branch
if [[ -n "${branch}" ]]; then if [[ -n "${branch}" ]]; then
# Check if branch exist # Check if branch exist
if [[ $(git show-ref refs/heads/"${branch}") ]] ; then if [[ $(git show-ref refs/heads/"${branch}") ]] ;
then
is_branch_existing=true is_branch_existing=true
_branch="${branch}" _branch="${branch}"
else else
@@ -671,7 +870,7 @@ function toJsonProp() {
# add in hold buffer and loop while the string is not finished. # add in hold buffer and loop while the string is not finished.
/^'"$propTag"',?\r?$/ ! { H; n; b eos; } /^'"$propTag"',?\r?$/ ! { H; n; b eos; }
# end of the string, flip buffer to current pattern. # end of the string, flip buffer to current pattern.
# keeps the comma if any, or a space as an empty placeholder. # keeps the comma if any, or a space as an empty placeholder.
/,\r?$/ ! { x; s/\r?$/ / } /,\r?$/ ! { x; s/\r?$/ / }
/,\r?$/ { x; s/\r?$/,/ } /,\r?$/ { x; s/\r?$/,/ }
} }
@@ -891,7 +1090,8 @@ function commitsByYear() {
echo -e "\tyear\tsum" echo -e "\tyear\tsum"
# Add time strings to make these a touch more robust # Add time strings to make these a touch more robust
for year in $(seq "$startYear" "$endYear"); do for year in $(seq "$startYear" "$endYear");
do
if [[ "$year" = "$startYear" ]]; then if [[ "$year" = "$startYear" ]]; then
__since=$_since __since=$_since
__until="--until=$year-12-31 23:59:59" __until="--until=$year-12-31 23:59:59"
@@ -918,13 +1118,12 @@ function commitsByYear() {
} }
END{ END{
for (year in count) { for (year in count) {
s="|"; s="|";
if (total > 0) { if (total > 0) {
percent = ((count[year] / total) * 100) / 1.25; percent = ((count[year] / total) * 100) / 1.25; for (i = 1; i <= percent; ++i) {
for (i = 1; i <= percent; ++i) {
s=s"█" s=s"█"
} }
printf( "\t%s\t%-0s\t%s\n", year, count[year], s ); printf( "\t%s\t%-0s\t%s\n", year, count[year], s );
} }
} }
}' | sort }' | sort
@@ -951,13 +1150,12 @@ function commitsByMonth() {
} }
END{ END{
for (month in count) { for (month in count) {
s="|"; s="|";
if (total > 0) { if (total > 0) {
percent = ((count[month] / total) * 100) / 1.25; percent = ((count[month] / total) * 100) / 1.25; for (i = 1; i <= percent; ++i) {
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 }' | LC_TIME="en_EN.UTF-8" sort -M
@@ -986,25 +1184,22 @@ function commitsByWeekday() {
do do
echo -en "\t$counter\t$i\t" echo -en "\t$counter\t$i\t"
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \ git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
"${_author}" "$_since" "$_until" $_log_options | "${_author}" "$_since" "$_until" $_log_options | grep -cE "^ * $i \w\w\w [0-9]{1,2} " || continue
grep -cE "^ * $i \w\w\w [0-9]{1,2} " || continue
counter=$((counter+1)) counter=$((counter+1))
done | awk '{ done | awk '{
} }
NR == FNR { NR == FNR {
count[$1" "$2] = $3; count[$1" "$2] = $3; total += $3;
total += $3;
next next
} }
END{ END{
for (day in count) { for (day in count) {
s="|"; s="|"; if (total > 0) {
if (total > 0) { percent = ((count[day] / total) * 100) / 1.25;
percent = ((count[day] / total) * 100) / 1.25;
for (i = 1; i <= percent; ++i) { for (i = 1; i <= percent; ++i) {
s=s"█" s=s"█"
} }
printf("\t%s\t%s\t%-0s\t%s\n", substr(day,0,1), substr(day,3,5), count[day], s); printf("\t%s\t%s\t%-0s\t%s\n", substr(day,0,1), substr(day,3,5), count[day], s);
} }
} }
}' | sort -k 1 -n | awk '{$1=""}1' | awk '{$1=$1}1' \ }' | sort -k 1 -n | awk '{$1=""}1' | awk '{$1=$1}1' \
@@ -1034,21 +1229,19 @@ function commitsByHour() {
do do
echo -ne "\t$i\t" echo -ne "\t$i\t"
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \ git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
"${_author}" "$_since" "$_until" $_log_options | "${_author}" "$_since" "$_until" $_log_options | grep -cE '[0-9] '$i':[0-9]' || continue
grep -cE '[0-9] '$i':[0-9]' || continue
done | awk '{ done | awk '{
count[$1] = $2 count[$1] = $2
total += $2 total += $2
} }
END{ END{
for (hour in count) { for (hour in count) {
s="|"; s="|";
if (total > 0) { if (total > 0) {
percent = ((count[hour] / total) * 100) / 1.25; percent = ((count[hour] / total) * 100) / 1.25; for (i = 1; i <= percent; ++i) {
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 }' | sort
@@ -1111,7 +1304,8 @@ if ! git rev-parse --is-inside-work-tree > /dev/null; then
exit 1 exit 1
fi fi
# Parse non-interative commands
# Parse non-interactive commands
if [[ "$#" -eq 1 ]]; then if [[ "$#" -eq 1 ]]; then
case "$1" in case "$1" in
# GENERATE OPTIONS # GENERATE OPTIONS
@@ -1197,105 +1391,109 @@ if [[ "$#" -eq 1 ]]; then
read -r -p "Which author? " author read -r -p "Which author? " author
done done
commitsByTimezone "${author}";; commitsByTimezone "${author}";;
# ACTIVITY OPTIONS # CALENDAR OPTIONS
-k|--commits-calendar-by-author) -k|--commits-calendar-by-author)
author="${_GIT_AUTHOR:-}" author="${_GIT_AUTHOR:-}"
while [[ -z "${author}" ]]; do while [[ -z "${author}" ]]; do
read -r -p "Which author? " author read -r -p "Which author? " author
done done
commitsCalendarByAuthor "${author}";; commitsCalendarByAuthor "${author}";;
-H|--commits-heatmap) commitsHeatmap;;
# SUGGEST OPTIONS # SUGGEST OPTIONS
-r|--suggest-reviewers) suggestReviewers;; -r|--suggest-reviewers) suggestReviewers;;
-h|-\?|--help) usage;; -h|-\?|--help) usage;;
*) echo "Invalid argument"; usage; exit 1;; *) echo "Invalid argument: $1"; usage; exit 1;;
esac esac
exit 0; exit 0;
fi fi
[[ "$#" -gt 1 ]] && { echo "Invalid arguments"; usage; exit 1; } [[ "$#" -gt 1 ]] && { echo "Invalid arguments"; usage; exit 1; }
# Parse interactive commands # If no args, run interactive mode
clear if [[ "$#" -eq 0 ]]; then
showMenu # Parse interactive commands
while [[ "${opt}" != "" ]]; do
clear clear
case "${opt}" in showMenu
1) detailedGitStats; showMenu;;
2) branch="" while [[ "${opt}" != "" ]]; do
while [[ -z "${branch}" ]]; do clear
read -r -p "Which branch? " branch case "${opt}" in
done 1) detailedGitStats; showMenu;;
detailedGitStats "${branch}"; showMenu;; 2) branch=""
3) changelogs; showMenu;; while [[ -z "${branch}" ]]; do
4) author="" read -r -p "Which branch? " branch
while [[ -z "${author}" ]]; do done
read -r -p "Which author? " author detailedGitStats "${branch}"; showMenu;;
done 3) changelogs; showMenu;;
changelogs "${author}"; showMenu;; 4) author=""
5) myDailyStats; showMenu;; while [[ -z "${author}" ]]; do
6) branch="" read -r -p "Which author? " author
while [[ -z "${branch}" ]]; do done
read -r -p "Which branch? " branch changelogs "${author}"; showMenu;;
done 5) myDailyStats; showMenu;;
csvOutput "${branch}"; showMenu;; 6) branch=""
7) json_path="" while [[ -z "${branch}" ]]; do
while [[ -z "${json_path}" ]]; do read -r -p "Which branch? " branch
echo "NOTE: This feature is in beta!" done
echo "The file name will be saved as \"output.json\"." csvOutput "${branch}"; showMenu;;
echo "The full path must be provided." 7) json_path=""
echo "Variables, subshell commands, or shorthands such as ~ may not be valid." while [[ -z "${json_path}" ]]; do
echo "You do not need the final slash at the end of a directory path." echo "NOTE: This feature is in beta!"
echo "You must have write permission to the folder you are trying to save this to." echo "The file name will be saved as \"output.json\"."
echo "This feature only works interactively and cannot be combined with other options." echo "The full path must be provided."
echo -e "Example of a valid path: /home/$(whoami)\n" echo "Variables, subshell commands, or shorthands such as ~ may not be valid."
read -r -p "Please provide the full path to directory to save JSON file: " json_path echo "You do not need the final slash at the end of a directory path."
if [[ ! -w "${json_path}" ]]; then echo "You must have write permission to the folder you are trying to save this to."
echo "Invalid path or permission denied to write to given area." echo "This feature only works interactively and cannot be combined with other options."
json_path="" echo -e "Example of a valid path: /home/$(whoami)\n"
fi read -r -p "Please provide the full path to directory to save JSON file: " json_path
done if [[ ! -w "${json_path}" ]]; then
jsonOutput "${json_path}"; showMenu;; echo "Invalid path or permission denied to write to given area."
8) branchTree; showMenu;; json_path=""
9) branchesByDate; showMenu;; fi
10) contributors; showMenu;; done
11) newDate="" jsonOutput "${json_path}"; showMenu;;
while [[ -z "${newDate}" ]]; do 8) branchTree; showMenu;;
read -r -p "Since what date? (e.g. '2023-04-13', '13 April 2023', 'last Thursday') " newDate 9) branchesByDate; showMenu;;
# Test if the date provide is valid and try again if it isn't. 10) contributors; showMenu;;
if ! date -d "${newDate}" +%s > /dev/null 2>&1; then 11) newDate=""
newDate="" while [[ -z "${newDate}" ]]; do
fi read -r -p "Since what date? (e.g. '2023-04-13', '13 April 2023', 'last Thursday') " newDate
done if ! date -d "${newDate}" +%s > /dev/null 2>&1; then
newContributors "${newDate}"; showMenu;; newDate=""
12) commitsPerAuthor; showMenu;; fi
13) commitsPerDay; showMenu;; done
14) commitsByMonth; showMenu;; newContributors "${newDate}"; showMenu;;
15) commitsByYear; showMenu;; 12) commitsPerAuthor; showMenu;;
16) commitsByWeekday; showMenu;; 13) commitsPerDay; showMenu;;
17) author="" 14) commitsByMonth; showMenu;;
while [[ -z "${author}" ]]; do 15) commitsByYear; showMenu;;
read -r -p "Which author? " author 16) commitsByWeekday; showMenu;;
done 17) author=""
commitsByWeekday "${author}"; showMenu;; while [[ -z "${author}" ]]; do
18) commitsByHour; showMenu;; read -r -p "Which author? " author
19) author="" done
while [[ -z "${author}" ]]; do commitsByWeekday "${author}"; showMenu;;
read -r -p "Which author? " author 18) commitsByHour; showMenu;;
done 19) author=""
commitsByHour "${author}"; showMenu;; while [[ -z "${author}" ]]; do
20) commitsByTimezone; showMenu;; read -r -p "Which author? " author
21) author="" done
while [[ -z "${author}" ]]; do commitsByHour "${author}"; showMenu;;
read -r -p "Which author? " author 20) commitsByTimezone; showMenu;;
done 21) author=""
commitsByTimezone "${author}"; showMenu;; while [[ -z "${author}" ]]; do
22) suggestReviewers; showMenu;; read -r -p "Which author? " author
23) author="" done
while [[ -z "${author}" ]]; do commitsByTimezone "${author}"; showMenu;;
read -r -p "Which author? " author 22) suggestReviewers; showMenu;;
done 23) author=""
commitsCalendarByAuthor "${author}"; showMenu;; while [[ -z "${author}" ]]; do
q|"\n") exit;; read -r -p "Which author? " author
*) clear; optionPicked "Pick an option from the menu"; showMenu;; done
esac commitsCalendarByAuthor "${author}"; showMenu;;
done 24) commitsHeatmap; showMenu;;
q|"\n") exit;;
*) clear; optionPicked "Pick an option from the menu"; showMenu;;
esac
done
fi

View File

@@ -1,209 +1,206 @@
.TH git-quick-stats "1" "June 2025" "git-quick-stats" "User Commands" .TH git-quick-stats "1" "June 2025" "git-quick-stats" "User Commands"
.SH NAME .SH NAME
.B git\-quick\-stats .B git\-quick\-stats
\- Simple and efficient way to access various stats in a git repository. \- Simple and efficient way to access various stats in a git repository.
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
For non\-interactive mode: For non\-interactive mode:
.B git\-quick\-stats [OPTIONS] .B git\-quick\-stats [OPTIONS]
.PP .PP
For interactive mode: For interactive mode:
.B git-quick-stats .B git-quick-stats
.PP .PP
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
Any git repository contains tons of information about commits, contributors, Any git repository contains tons of information about commits, contributors,
and files. Extracting this information is not always trivial, mostly because and files. Extracting this information is not always trivial, mostly because
of a gadzillion options to a gadzillion git commands. of a gadzillion options to a gadzillion git commands.
This program allows you to see detailed information about a git repository. This program allows you to see detailed information about a git repository.
.PP .PP
.SH GENERATE OPTIONS .SH GENERATE OPTIONS
.PP .PP
\fB\-T\fR, \fB\-\-detailed\-git\-stats\fR \fB\-h\fR, \-?, \fB\-\-help\fR
.IP .IP
give a detailed list of git stats display this help text in the terminal
.HP .PP
.PP \fB\-T\fR, \fB\-\-detailed\-git\-stats\fR
\fB\-R\fR, \fB\-\-git\-stats\-by\-branch\fR .IP
.IP give a detailed list of git stats
see detailed list of git stats by branch .HP
.HP .PP
.PP \fB\-R\fR, \fB\-\-git\-stats\-by\-branch\fR
\fB\-c\fR, \fB\-\-changelogs\fR .IP
.IP see detailed list of git stats by branch
see changelogs .HP
.HP .PP
.PP \fB\-c\fR, \fB\-\-changelogs\fR
\fB\-L\fR, \fB\-\-changelogs\-by\-author\fR .IP
.IP see changelogs
see changelogs by author .HP
.HP .PP
.PP \fB\-L\fR, \fB\-\-changelogs\-by\-author\fR
\fB\-S\fR, \fB\-\-my\-daily\-stats\fR .IP
.IP see changelogs by author
see your current daily stats .HP
.HP .PP
.PP \fB\-S\fR, \fB\-\-my\-daily\-stats\fR
\fB\-V\fR, \fB\-\-csv\-output\-by\-branch\fR .IP
.IP see your current daily stats
output daily stats by branch in CSV format .HP
.HP .PP
.PP \fB\-V\fR, \fB\-\-csv\-output\-by\-branch\fR
\fB\-j\fR, \fB\-\-json\-output\fR .IP
.IP output daily stats by branch in CSV format
save git log as a JSON formatted file to a specified area .HP
.HP .PP
.SH LIST OPTIONS \fB\-j\fR, \fB\-\-json\-output\fR
.PP .IP
\fB\-b\fR, \fB\-\-branch\-tree\fR save git log as a JSON formatted file to a specified area
.IP .HP
show an ASCII graph of the git repo branch history .SH LIST OPTIONS
.HP .PP
.PP \fB\-b\fR, \fB\-\-branch\-tree\fR
\fB\-D\fR, \fB\-\-branches\-by\-date\fR .IP
.IP show an ASCII graph of the git repo branch history
show branches by date .HP
.HP .PP
.PP \fB\-D\fR, \fB\-\-branches\-by\-date\fR
\fB\-C\fR, \fB\-\-contributors\fR .IP
.IP show branches by date
see a list of everyone who contributed to the repo .HP
.HP .PP
.PP \fB\-C\fR, \fB\-\-contributors\fR
\fB\-n\fR, \fB\-\-new\-contributors\fR .IP
.IP see a list of everyone who contributed to the repo
list everyone who made their first contribution since a specified date .HP
.HP .PP
.PP \fB\-n\fR, \fB\-\-new\-contributors\fR
\fB\-a\fR, \fB\-\-commits\-per\-author\fR .IP
.IP list everyone who made their first contribution since a specified date
displays a list of commits per author .HP
.HP .PP
.PP \fB\-a\fR, \fB\-\-commits\-per\-author\fR
\fB\-d\fR, \fB\-\-commits\-per\-day\fR .IP
.IP displays a list of commits per author
displays a list of commits per day .HP
.HP .PP
.PP \fB\-d\fR, \fB\-\-commits\-per\-day\fR
\fB\-m\fR, \fB\-\-commits\-by\-month\fR .IP
.IP displays a list of commits per day
displays a list of commits per month .HP
.HP .PP
.PP \fB\-m\fR, \fB\-\-commits\-by\-month\fR
\fB\-Y\fR, \fB\-\-commits\-by\-year\fR .IP
.IP displays a list of commits per month
displays a list of commits per year .HP
.HP .PP
.PP \fB\-Y\fR, \fB\-\-commits\-by\-year\fR
\fB\-w\fR, \fB\-\-commits\-by\-weekday\fR .IP
.IP displays a list of commits per year
displays a list of commits per weekday .HP
.HP .PP
.PP \fB\-w\fR, \fB\-\-commits\-by\-weekday\fR
\fB\-W\fR, \fB\-\-commits\-by\-author\-by\-weekday\fR .IP
.IP displays a list of commits per weekday
displays a list of commits per weekday by author .HP
.HP .PP
.PP \fB\-W\fR, \fB\-\-commits\-by\-author\-by\-weekday\fR
\fB\-o\fR, \fB\-\-commits\-by\-hour\fR .IP
.IP displays a list of commits per weekday by author
displays a list of commits per hour .HP
.HP .PP
.PP \fB\-o\fR, \fB\-\-commits\-by\-hour\fR
\fB\-A\fR, \fB\-\-commits\-by\-author\-by\-hour\fR .IP
.IP displays a list of commits per hour
displays a list of commits per hour by author .HP
.HP .PP
.PP \fB\-A\fR, \fB\-\-commits\-by\-author\-by\-hour\fR
\fB\-z\fR, \fB\-\-commits\-by\-timezone\fR .IP
.IP displays a list of commits per hour by author
displays a list of commits per timezone .HP
.HP .PP
.PP \fB\-z\fR, \fB\-\-commits\-by\-timezone\fR
\fB\-Z\fR, \fB\-\-commits\-by\-author\-by\-timezone\fR .IP
.IP displays a list of commits per timezone
displays a list of commits per timezone by author .HP
.HP .PP
.PP \fB\-Z\fR, \fB\-\-commits\-by\-author\-by\-timezone\fR
\fB\-\-activity\-calendar\fR .IP
.IP displays a list of commits per timezone by author
displays a calendar-style grid of commit activity per day-of-week and month for a selected author. .HP
.HP .PP
.SH SUGGEST OPTIONS \fB\-\-activity\-calendar\fR
.PP .IP
\fB\-r\fR, \fB\-\-suggest\-reviewers\fR displays a calendar-style grid of commit activity per day-of-week and month for a selected author.
.IP .HP
show the best people to contact to review code .SH SUGGEST OPTIONS
.HP .PP
.PP \fB\-r\fR, \fB\-\-suggest\-reviewers\fR
\fB\-h\fR, \-?, \fB\-\-help\fR .IP
.IP show the best people to contact to review code
display this help text in the terminal .HP
.PP .PP
.SH ADDITIONAL USAGE .SH CALENDAR OPTIONS
You can set _GIT_SINCE and _GIT_UNTIL to limit the git time log, example: .PP
.PP \fB\-k\fR, \fB\-\-commits\-calendar\-by\-author\fR outputs a visual grid of commit activity for a selected author, grouped by day-of-week (rows: Mon..Sun) and month (columns: Jan..Dec). Each cell is 3 characters wide, separated by one space.
.B export _GIT_SINCE="2017\-01\-20" .PP
.PP .PP
You can set _GIT_LIMIT for limited output log, example: \fB\-H\fR, \fB\-\-commits\-heatmap\fR shows a heatmap of commits per day per hour for the last 30 days
.PP .PP
.B export _GIT_LIMIT=20 .SH ADDITIONAL USAGE
.PP You can set _GIT_SINCE and _GIT_UNTIL to limit the git time log, example:
You can set _GIT_LOG_OPTIONS for git log options, example: .PP
.PP .B export _GIT_SINCE="2017\-01\-20"
.B export _GIT_LOG_OPTIONS="--ignore-all-space --ignore-blank-lines" .PP
.PP You can set _GIT_LIMIT for limited output log, example:
You can exclude directories or files from the stats by using pathspec, example: .PP
.PP .B export _GIT_LIMIT=20
.B export _GIT_PATHSPEC=':!pattern' .PP
.PP You can set _GIT_LOG_OPTIONS for git log options, example:
You can set _GIT_MERGE_VIEW to show merge commits with normal commits, example: .PP
.PP .B export _GIT_LOG_OPTIONS="--ignore-all-space --ignore-blank-lines"
.B export _GIT_MERGE_VIEW="enable" .PP
.PP You can exclude directories or files from the stats by using pathspec, example:
You can also set _GIT_MERGE_VIEW to only show merge commits, example: .PP
.PP .B export _GIT_PATHSPEC=':!pattern'
.B export _GIT_MERGE_VIEW="exclusive" .PP
.PP You can set _GIT_MERGE_VIEW to show merge commits with normal commits, example:
You can change to the legacy color scheme by toggling the variable `_MENU_THEME` between `default` and `legacy`. You can completely disable the color theme by setting the `_MENU_THEME` variable to `none`, example: .PP
.PP .B export _GIT_MERGE_VIEW="enable"
.B export _MENU_THEME=legacy .PP
.PP You can also set _GIT_MERGE_VIEW to only show merge commits, example:
or .PP
.B export _MENU_THEME=none .B export _GIT_MERGE_VIEW="exclusive"
.PP .PP
You can set _GIT_BRANCH to set the branch of the stats, example: You can sort contribution stats by field "name", "commits", "insertions", "deletions", or "lines" (total lines changed) and order ("asc", "desc"). e.g.: "commits-desc"
.PP .PP
.B export _GIT_BRANCH="master" .B export _GIT_SORT_BY="name-asc"
.PP .PP
.SH Calendar activity output You can change to the legacy color scheme by toggling the variable "_MENU_THEME" between "default" and "legacy". You can completely disable the color theme by setting the "_MENU_THEME" variable to "none", example:
.PP .PP
\fBactivity-calendar\fR outputs a visual grid of commit activity for a selected author, grouped by day-of-week (rows: Mon..Sun) and month (columns: Jan..Dec). Each cell is 3 characters wide, separated by one space. .B export _MENU_THEME=legacy
.PP .PP
Sample output: or
.PP .B export _MENU_THEME=none
.nf .PP
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec You can set _GIT_BRANCH to set the branch of the stats, example:
Mon ▓▓▓ ░░░ ▒▒▒ ░░░ ░░░ ▒▒▒ ▓▓▓ ░░░ ░░░ ▓▓▓ ▒▒▒ ▒▒▒ .PP
Tue ▒▒▒ ░░░ ▒▒▒ ░░░ ▒▒▒ ░░░ ▒▒▒ ▓▓▓ ▒▒▒ ░░░ ░░░ ░░░ .B export _GIT_BRANCH="master"
Wed ░░░ ▓▓▓ ░░░ ▓▓▓ ▒▒▒ ░░░ ░░░ ▒▒▒ ░░░ ░░░ ▓▓▓ ░░░ .PP
Thu ░░░ ▒▒▒ ░░░ ░░░ ▒▒▒ ░░░ ▓▓▓ ▒▒▒ ▒▒▒ ░░░ ░░░ ▒▒▒ You can set _GIT_IGNORE_AUTHORS to filter out specific authors, example:
Fri ▒▒▒ ░░░ ▒▒▒ ▓▓▓ ░░░ ▓▓▓ ▒▒▒ ░░░ ▒▒▒ ░░░ ▒▒▒ ░░░ .PP
Sat ░░░ ░░░ ▒▒▒ ░░░ ░░░ ░░░ ▒▒▒ ░░░ ▒▒▒ ▓▓▓ ▒▒▒ ░░░ .B export _GIT_IGNORE_AUTHORS="(author@examle.com|username)"
Sun ▓▓▓ ░░░ ▓▓▓ ░░░ ░░░ ▓▓▓ ░░░ ▒▒▒ ░░░ ░░░ ▓▓▓ ░░░ .PP
You can set _GIT_DAYS to set the number of days for the heatmap, example:
Legend: ... = 0 ░░░ = 12 ▒▒▒ = 35 ▓▓▓ = 6+ commits .PP
.PP .B export _GIT_DAYS=30"
You can set _GIT_IGNORE_AUTHORS to filter out specific authors, example: .
.PP .fi
.B export _GIT_IGNORE_AUTHORS="(author@examle.com|username)"
. .PP
.fi .SH SEE ALSO
.BR git (1)
.PP .PP
.SH SEE ALSO Project homepage:
.BR git (1) .UR https://github.com/git-quick-stats/git-quick-stats
.PP
Project homepage:
.UR https://github.com/git-quick-stats/git-quick-stats
.UE .UE

View File

@@ -11,7 +11,7 @@
. tests/assert.sh -v . tests/assert.sh -v
src="./git-quick-stats" src="./git-quick-stats"
assert "$src fail" "Invalid argument assert "$src fail" "Invalid argument: fail
NAME NAME
git-quick-stats - Simple and efficient way to access various stats in a git repo git-quick-stats - Simple and efficient way to access various stats in a git repo
@@ -24,7 +24,7 @@ DESCRIPTION
Any git repository contains tons of information about commits, contributors, Any git repository contains tons of information about commits, contributors,
and files. Extracting this information is not always trivial, mostly because and files. Extracting this information is not always trivial, mostly because
of a gadzillion options to a gadzillion git commands. of a gadzillion options to a gadzillion git commands.
This program allows you to see detailed information about a git repository. This program allows you to see detailed information about a git repository.
GENERATE OPTIONS GENERATE OPTIONS
@@ -73,6 +73,12 @@ LIST OPTIONS
-Z, --commits-by-author-by-timezone -Z, --commits-by-author-by-timezone
displays a list of commits per timezone by author displays a list of commits per timezone by author
CALENDAR OPTIONS
-k, --commits-calendar-by-author
shows a calendar heatmap of commits per day-of-week per month for a given author
-H, --commits-heatmap
shows a heatmap of commits per day-of-week per month for the last 30 days
SUGGEST OPTIONS SUGGEST OPTIONS
-r, --suggest-reviewers -r, --suggest-reviewers
show the best people to contact to review code show the best people to contact to review code
@@ -98,14 +104,18 @@ ADDITIONAL USAGE
You can set _GIT_BRANCH to set the branch of the stats You can set _GIT_BRANCH to set the branch of the stats
ex: export _GIT_BRANCH=master ex: export _GIT_BRANCH=master
You can set _GIT_IGNORE_AUTHORS to filter out specific authors You can set _GIT_IGNORE_AUTHORS to filter out specific authors
ex: export _GIT_IGNORE_AUTHORS=\"(author1|author2)\"" ex: export _GIT_IGNORE_AUTHORS=\"(author1|author2)\"
You can sort contribution stats by field \"name\", \"commits\", \"insertions\", \"deletions\", or \"lines\" - total lines changed and order - \"asc\", \"desc\"
ex: export _GIT_SORT_BY=\"name-asc\"
You can set _GIT_DAYS to set the number of days for the heatmap
ex: export _GIT_DAYS=30"
assert_raises "$src fail" 1 assert_raises "$src fail" 1
assert_contains "$src --suggest-reviewers" "Suggested code reviewers (based on git history)" assert_contains "$src --suggest-reviewers" "Suggested code reviewers (based on git history)"
assert_success "$src --suggest-reviewers" assert_success "$src --suggest-reviewers"
assert_contains "$src --detailed-git-stats" "Contribution stats" assert_contains "$src --detailed-git-stats" "Contribution stats (by author) on the current branch"
assert_success "$src --detailed-git-stats" assert_success "$src --detailed-git-stats"
assert_contains "$src --commits-per-day" "Git commits per date" assert_contains "$src --commits-per-day" "Git commits per date"