mirror of
https://github.com/git-quick-stats/git-quick-stats.git
synced 2025-12-16 12:00:12 +01:00
Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
125eec7136 | ||
|
|
d61c812247 | ||
|
|
261262ab4e | ||
|
|
e968ef62b9 | ||
|
|
74261c1e50 | ||
|
|
4eade09673 | ||
|
|
47a9151886 | ||
|
|
916d5e1e0f | ||
|
|
17a9d1427b | ||
|
|
091562d4f8 | ||
|
|
748576b541 | ||
|
|
f43ab22172 | ||
|
|
4d2e52aa6d | ||
|
|
08c0ca1d85 | ||
|
|
e8843da10e | ||
|
|
376887a394 | ||
|
|
cebb5a8f48 | ||
|
|
343351b762 | ||
|
|
95136d3f92 | ||
|
|
79c735c814 | ||
|
|
ec6a95d2ef | ||
|
|
b65b100cd8 | ||
|
|
dd7719c3b0 | ||
|
|
c34ceb4c0e | ||
|
|
850b7453eb | ||
|
|
5063d1aad7 | ||
|
|
53b9971cf7 | ||
|
|
eec6d53ce9 | ||
|
|
d06a7ca090 | ||
|
|
462439a855 | ||
|
|
c467a9694b | ||
|
|
d4f71cfdad | ||
|
|
88e369503e | ||
|
|
afd61ce9c2 | ||
|
|
e1e02024a1 | ||
|
|
d1641f7bf3 | ||
|
|
8de8c43212 | ||
|
|
f4ec72073d | ||
|
|
b0003bef49 | ||
|
|
a833a5f431 | ||
|
|
886f64f086 | ||
|
|
115b21a48d | ||
|
|
4d515b88b3 | ||
|
|
9b3c0e5db1 | ||
|
|
86ad0af8bb | ||
|
|
fb488abe3e | ||
|
|
3cce04ddad | ||
|
|
d4e56cf557 |
5
.github/FUNDING.yml
vendored
5
.github/FUNDING.yml
vendored
@@ -1,6 +1 @@
|
|||||||
# These are supported funding model platforms
|
# These are supported funding model platforms
|
||||||
|
|
||||||
github: [arzzen]
|
|
||||||
open_collective: git-quick-stats
|
|
||||||
ko_fi: lukasmestan
|
|
||||||
custom: ['https://lukasmestan.com/thanks/']
|
|
||||||
|
|||||||
4
.mailmap
4
.mailmap
@@ -1,3 +1,3 @@
|
|||||||
Lukas Mestan <lukas.mestan@gmail.com> Lukáš Mešťan <arzzen@users.noreply.github.com>
|
Lukas <test@gmail.com> Lukáš <arzzen@users.noreply.github.com>
|
||||||
Lukas Mestan <lukas.mestan@gmail.com> arzzen
|
Lukas <lukas@gmail.com> arzzen
|
||||||
|
|
||||||
|
|||||||
25
CITATION.cff
Normal file
25
CITATION.cff
Normal 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
|
||||||
@@ -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 \
|
||||||
@@ -23,5 +23,6 @@ ENV _GIT_SINCE= \
|
|||||||
TERM=xterm-256color
|
TERM=xterm-256color
|
||||||
|
|
||||||
WORKDIR /git
|
WORKDIR /git
|
||||||
|
RUN git config --global --add safe.directory /git
|
||||||
ENTRYPOINT [ "/usr/local/bin/docker-entrypoint" ]
|
ENTRYPOINT [ "/usr/local/bin/docker-entrypoint" ]
|
||||||
CMD [ "/usr/bin/git", "quick-stats" ]
|
CMD [ "/usr/bin/git", "quick-stats" ]
|
||||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2021 Lukáš Mešťan
|
Copyright (c) 2024 git-quick-stats.sh
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -30,8 +30,8 @@ uninstall:
|
|||||||
@$(TASK_DONE)
|
@$(TASK_DONE)
|
||||||
|
|
||||||
reinstall:
|
reinstall:
|
||||||
@curl -sO https://raw.githubusercontent.com/arzzen/git-quick-stats/master/git-quick-stats
|
@curl -sO https://raw.githubusercontent.com/git-quick-stats/git-quick-stats/master/git-quick-stats
|
||||||
@curl -sO https://raw.githubusercontent.com/arzzen/git-quick-stats/master/git-quick-stats.1
|
@curl -sO https://raw.githubusercontent.com/git-quick-stats/git-quick-stats/master/git-quick-stats.1
|
||||||
$(MAKE) install
|
$(MAKE) install
|
||||||
@$(TASK_DONE)
|
@$(TASK_DONE)
|
||||||
|
|
||||||
|
|||||||
156
README.md
156
README.md
@@ -1,12 +1,12 @@
|
|||||||
# GIT quick statistics [](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 [](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)
|
||||||
|
|
||||||
[](#backers) [](#sponsors) [](https://formulae.brew.sh/formula/git-quick-stats#default)
|
[](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 :).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
@@ -14,34 +14,34 @@
|
|||||||
|
|
||||||
[**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)
|
||||||
|
|
||||||
@@ -49,14 +49,16 @@
|
|||||||
|
|
||||||
[**Contributors**](#contributors)
|
[**Contributors**](#contributors)
|
||||||
|
|
||||||
* [**Backers**](#backers)
|
- [**Backers**](#backers)
|
||||||
* [**Sponsors**](#sponsors)
|
- [**Sponsors**](#sponsors)
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -122,10 +124,10 @@ LIST OPTIONS
|
|||||||
displays a list of commits per author
|
displays a list of commits per author
|
||||||
-d, --commits-per-day
|
-d, --commits-per-day
|
||||||
displays a list of commits per day
|
displays a list of commits per day
|
||||||
-Y, --commits-by-year
|
|
||||||
displays a list of commits per year
|
|
||||||
-m, --commits-by-month
|
-m, --commits-by-month
|
||||||
displays a list of commits per month
|
displays a list of commits per month
|
||||||
|
-Y, --commits-by-year
|
||||||
|
displays a list of commits per year
|
||||||
-w, --commits-by-weekday
|
-w, --commits-by-weekday
|
||||||
displays a list of commits per weekday
|
displays a list of commits per weekday
|
||||||
-W, --commits-by-author-by-weekday
|
-W, --commits-by-author-by-weekday
|
||||||
@@ -139,6 +141,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
|
||||||
@@ -204,12 +212,39 @@ You can set the variable `_GIT_BRANCH` to set the branch of the stats. Works wit
|
|||||||
export _GIT_BRANCH="master"
|
export _GIT_BRANCH="master"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Ignore authors
|
||||||
|
|
||||||
|
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 _GIT_IGNORE_AUTHORS="(author@examle.com|username)"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sorting contribution stats
|
||||||
|
|
||||||
|
You can sort contribution stats by field `name`, `commits`, `insertions`, `deletions`, or `lines` (total lines changed) and order (`asc`, `desc`). e.g.: `commits-desc`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export _GIT_SORT_BY="name-asc"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Commit days
|
||||||
|
|
||||||
|
You can set \_GIT_DAYS to set the number of days for the heatmap
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export _GIT_DAYS=30
|
||||||
|
```
|
||||||
|
|
||||||
### Color themes
|
### Color themes
|
||||||
|
|
||||||
You can change to the legacy color scheme by toggling the variable `_MENU_THEME` between `default` and `legacy`
|
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`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export _MENU_THEME="legacy"
|
export _MENU_THEME="legacy"
|
||||||
|
# or
|
||||||
|
export _MENU_THEME="none"
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@@ -227,7 +262,7 @@ apt install git-quick-stats
|
|||||||
### UNIX and Linux
|
### UNIX and Linux
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/arzzen/git-quick-stats.git && cd git-quick-stats
|
git clone https://github.com/git-quick-stats/git-quick-stats.git && cd git-quick-stats
|
||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -271,8 +306,8 @@ based on the shell of your choice.
|
|||||||
|
|
||||||
If you are installing with Cygwin, use these scripts:
|
If you are installing with Cygwin, use these scripts:
|
||||||
|
|
||||||
* [installer](https://gist.github.com/arzzen/35e09866dfdadf2108b2420045739245)
|
- [installer](https://gist.github.com/arzzen/35e09866dfdadf2108b2420045739245)
|
||||||
* [uninstaller](https://gist.github.com/arzzen/21c660014d0663b6c5710014714779d6)
|
- [uninstaller](https://gist.github.com/arzzen/21c660014d0663b6c5710014714779d6)
|
||||||
|
|
||||||
If you are wishing to use this with WSL, follow the UNIX and Linux instructions.
|
If you are wishing to use this with WSL, follow the UNIX and Linux instructions.
|
||||||
|
|
||||||
@@ -280,14 +315,14 @@ If you are wishing to use this with WSL, follow the UNIX and Linux instructions.
|
|||||||
|
|
||||||
You can use the Docker image provided:
|
You can use the Docker image provided:
|
||||||
|
|
||||||
* Build: `docker build -t arzzen/git-quick-stats .`
|
- Build: `docker build -t arzzen/git-quick-stats .`
|
||||||
* Run interactive menu: `docker run --rm -it -v $(pwd):/git arzzen/git-quick-stats`
|
- 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)
|
- Docker pull command: `docker pull arzzen/git-quick-stats` [docker repository](https://hub.docker.com/r/arzzen/git-quick-stats)
|
||||||
|
|
||||||
## System requirements
|
## System requirements
|
||||||
|
|
||||||
* An OS with a Bash shell
|
- An OS with a Bash shell
|
||||||
* Tools we use:
|
- Tools we use:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
awk
|
awk
|
||||||
@@ -309,21 +344,21 @@ uniq
|
|||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
|
|
||||||
* [`bsdextrautils`](https://packages.debian.org/sid/bsdextrautils) `apt install bsdextrautils`
|
- [`bsdextrautils`](https://packages.debian.org/sid/bsdextrautils) `apt install bsdextrautils`
|
||||||
* [`coreutils`](https://packages.debian.org/sid/coreutils) `apt install coreutils`
|
- [`coreutils`](https://packages.debian.org/sid/coreutils) `apt install coreutils`
|
||||||
* [`gawk`](https://packages.debian.org/sid/gawk) `apt install gawk`
|
- [`gawk`](https://packages.debian.org/sid/gawk) `apt install gawk`
|
||||||
* [`grep`](https://packages.debian.org/sid/grep) `apt install grep`
|
- [`grep`](https://packages.debian.org/sid/grep) `apt install grep`
|
||||||
* [`ncurses-bin`](https://packages.debian.org/sid/ncurses-bin) `apt install ncurses-bin`
|
- [`ncurses-bin`](https://packages.debian.org/sid/ncurses-bin) `apt install ncurses-bin`
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
|
|
||||||
*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`
|
_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`
|
||||||
|
|
||||||
*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.
|
_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.
|
||||||
|
|
||||||
*Q:* How they could be used in a project with many git projects and statistics would show a summary of all git projects?
|
_Q:_ How they could be used in a project with many git projects and statistics would show a summary of all git projects?
|
||||||
|
|
||||||
*A:* If you want to include submodule logs, you can try using the following: `export _GIT_LOG_OPTIONS="-p --submodule=log"`
|
_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))
|
(more info about [git log --submodule](https://git-scm.com/docs/git-log#Documentation/git-log.txt---submoduleltformatgt))
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
@@ -337,13 +372,13 @@ We use GitHub pull requests for this purpose.
|
|||||||
|
|
||||||
### Some tips for good pull requests
|
### Some tips for good pull requests
|
||||||
|
|
||||||
* Use our code </br>
|
- Use our code </br>
|
||||||
When in doubt, try to stay true to the existing code of the project.
|
When in doubt, try to stay true to the existing code of the project.
|
||||||
* Write a descriptive commit message. What problem are you solving and what
|
- Write a descriptive commit message. What problem are you solving and what
|
||||||
are the consequences? Where and what did you test? Some good tips:
|
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)
|
[here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)
|
||||||
and [here](https://www.kernel.org/doc/Documentation/SubmittingPatches).
|
and [here](https://www.kernel.org/doc/Documentation/SubmittingPatches).
|
||||||
* If your PR consists of multiple commits which are successive improvements /
|
- If your PR consists of multiple commits which are successive improvements /
|
||||||
fixes to your first commit, consider squashing them into a single commit
|
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
|
(`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
|
HEAD. This make reviewing the code so much easier, and our history more
|
||||||
@@ -365,33 +400,12 @@ make test
|
|||||||
|
|
||||||
MIT see [LICENSE][] for the full license text.
|
MIT see [LICENSE][] for the full license text.
|
||||||
|
|
||||||
[read this page]: http://github.com/arzzen/git-quick-stats/blob/master/.github/CONTRIBUTING.md
|
[read this page]: http://github.com/git-quick-stats/git-quick-stats/blob/master/.github/CONTRIBUTING.md
|
||||||
[landing page]: http://arzzen.github.io/git-quick-stats
|
[landing page]: https://git-quick-stats.sh
|
||||||
[LICENSE]: https://github.com/arzzen/git-quick-stats/blob/master/LICENSE
|
[LICENSE]: https://github.com/git-quick-stats/git-quick-stats/blob/master/LICENSE
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
This project exists thanks to all the people who contribute.
|
This project exists thanks to all the people who contribute.
|
||||||
|
|
||||||
[](https://github.com/arzzen/git-quick-stats/graphs/contributors)
|
[](https://github.com/git-quick-stats/git-quick-stats/graphs/contributors)
|
||||||
|
|
||||||
### Backers
|
|
||||||
|
|
||||||
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/git-quick-stats#backer)]
|
|
||||||
|
|
||||||
[](https://opencollective.com/git-quick-stats#backers)
|
|
||||||
|
|
||||||
### Sponsors
|
|
||||||
|
|
||||||
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)]
|
|
||||||
|
|
||||||
[](https://opencollective.com/git-quick-stats/sponsor/0/website)
|
|
||||||
[](https://opencollective.com/git-quick-stats/sponsor/1/website)
|
|
||||||
[](https://opencollective.com/git-quick-stats/sponsor/2/website)
|
|
||||||
[](https://opencollective.com/git-quick-stats/sponsor/3/website)
|
|
||||||
[](https://opencollective.com/git-quick-stats/sponsor/4/website)
|
|
||||||
[](https://opencollective.com/git-quick-stats/sponsor/5/website)
|
|
||||||
[](https://opencollective.com/git-quick-stats/sponsor/6/website)
|
|
||||||
[](https://opencollective.com/git-quick-stats/sponsor/7/website)
|
|
||||||
[](https://opencollective.com/git-quick-stats/sponsor/8/website)
|
|
||||||
[](https://opencollective.com/git-quick-stats/sponsor/9/website)
|
|
||||||
|
|||||||
653
git-quick-stats
653
git-quick-stats
@@ -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)
|
||||||
@@ -17,7 +35,7 @@ _since=${_GIT_SINCE:-}
|
|||||||
if [[ -n "${_since}" ]]; then
|
if [[ -n "${_since}" ]]; then
|
||||||
_since="--since=$_since"
|
_since="--since=$_since"
|
||||||
else
|
else
|
||||||
_since="--since=$(git log --reverse --format='%ad' | head -n1)"
|
_since="--since=$(git log --reverse --format='%ad' --date=iso | head -n1)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# End of git log date. Respects all git datetime formats
|
# End of git log date. Respects all git datetime formats
|
||||||
@@ -27,7 +45,7 @@ _until=${_GIT_UNTIL:-}
|
|||||||
if [[ -n "${_until}" ]]; then
|
if [[ -n "${_until}" ]]; then
|
||||||
_until="--until=$_until"
|
_until="--until=$_until"
|
||||||
else
|
else
|
||||||
_until="--until=$(date '+%a, %d %b %Y %H:%M:%S %Z')"
|
_until="--until=$(LC_TIME=C date '+%a, %d %b %Y %H:%M:%S %Z')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set files or directories to be excluded in stats
|
# Set files or directories to be excluded in stats
|
||||||
@@ -68,10 +86,174 @@ else
|
|||||||
_log_options=""
|
_log_options=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Ignore author regex
|
||||||
|
_ignore_authors=${_GIT_IGNORE_AUTHORS:-}
|
||||||
|
if [[ -n "${_ignore_authors}" ]]; then
|
||||||
|
_ignore_authors=$_ignore_authors
|
||||||
|
else
|
||||||
|
_ignore_authors=""
|
||||||
|
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}"
|
||||||
|
|
||||||
|
# DESC: Shows a calendar heatmap of commits per day-of-week per month for a given author
|
||||||
|
# ARGS: $author (required)
|
||||||
|
function commitsCalendarByAuthor() {
|
||||||
|
local author="${1:-}"
|
||||||
|
[[ -z "$author" ]] && { echo "Usage: commitsCalendarByAuthor <author>"; return 1; }
|
||||||
|
|
||||||
|
optionPicked "Commit Activity Calendar for '$author'"
|
||||||
|
|
||||||
|
# Print header
|
||||||
|
printf "\n Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec\n"
|
||||||
|
|
||||||
|
# Gather commit counts
|
||||||
|
git -c log.showSignature=false log --use-mailmap $_merges \
|
||||||
|
--date=iso --author="$author" "$_since" "$_until" $_log_options \
|
||||||
|
--pretty='%ad' $_pathspec | awk '
|
||||||
|
{
|
||||||
|
split($0, a, " ");
|
||||||
|
# a[1] = YYYY-MM-DD
|
||||||
|
split(a[1], date_fields, "-");
|
||||||
|
mon = date_fields[2] + 0;
|
||||||
|
cmd = "date -d \"" a[1] "\" +%u";
|
||||||
|
cmd | getline weekday;
|
||||||
|
close(cmd);
|
||||||
|
# weekday: 1=Mon, ..., 7=Sun
|
||||||
|
count[weekday * 12 + mon]++;
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
# Output matrix
|
||||||
|
for (d=1; d<=7; d++) {
|
||||||
|
if (d==1) printf "Mon ";
|
||||||
|
else if (d==2) printf "Tue ";
|
||||||
|
else if (d==3) printf "Wed ";
|
||||||
|
else if (d==4) printf "Thu ";
|
||||||
|
else if (d==5) printf "Fri ";
|
||||||
|
else if (d==6) printf "Sat ";
|
||||||
|
else if (d==7) printf "Sun ";
|
||||||
|
for (m=1; m<=12; m++) {
|
||||||
|
c = count[d * 12 + m]+0;
|
||||||
|
if (c==0)
|
||||||
|
out="...";
|
||||||
|
else if (c<=9)
|
||||||
|
out="░░░";
|
||||||
|
else if (c<=19)
|
||||||
|
out="▒▒▒";
|
||||||
|
else
|
||||||
|
out="▓▓▓";
|
||||||
|
printf "%s%s", out, (m<12?" ":"\n"); }
|
||||||
|
}
|
||||||
|
printf "\nLegend: ... = 0 ░░░ = 1–9 ▒▒▒ = 10–19 ▓▓▓ = 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} 7–8 commits"
|
||||||
|
echo -e " ${COLOR_DEEP_RED}█${COLOR_RESET} 9–10 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
|
||||||
|
|
||||||
@@ -118,24 +300,6 @@ function optionPicked() {
|
|||||||
echo -e "${msg}\n"
|
echo -e "${msg}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# DESC: Format date string
|
|
||||||
# ARGS: $* (required): String
|
|
||||||
# OUTS: String
|
|
||||||
################################################################################
|
|
||||||
function format_date() {
|
|
||||||
# NOTE: While this works where it's implemented within the changelogs()
|
|
||||||
# function the first time, it then bombs out when it reaches the -d flag
|
|
||||||
# in the second half of that same code as BSD date cannot handle -d, nor
|
|
||||||
# can it handle a string such as DATE - 1 day.
|
|
||||||
local date="${1}"
|
|
||||||
local outf="${2}"
|
|
||||||
local datef="${3:-"%b %d %H:%M:%S %Y %Z"}" # Tue Oct 24 13:34:22 2023 +0300
|
|
||||||
local resp="$(date -d "${date}" "+${outf}")"
|
|
||||||
|
|
||||||
printf "%s" "${resp}"
|
|
||||||
}
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# DESC: Help information printed to stdout during non-interactive mode
|
# DESC: Help information printed to stdout during non-interactive mode
|
||||||
# ARGS: None
|
# ARGS: None
|
||||||
@@ -205,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
|
||||||
@@ -224,10 +394,17 @@ ADDITIONAL USAGE
|
|||||||
ex: export _GIT_MERGE_VIEW=enable
|
ex: export _GIT_MERGE_VIEW=enable
|
||||||
You can also set _GIT_MERGE_VIEW to only show merge commits
|
You can also set _GIT_MERGE_VIEW to only show merge commits
|
||||||
ex: export _GIT_MERGE_VIEW=exclusive
|
ex: export _GIT_MERGE_VIEW=exclusive
|
||||||
You can set _MENU_THEME to display the legacy color scheme
|
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\".
|
||||||
ex: export _MENU_THEME=legacy
|
ex: export _MENU_THEME=legacy
|
||||||
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
|
||||||
|
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"
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -237,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=""
|
||||||
@@ -250,21 +421,31 @@ function showMenu() {
|
|||||||
EXIT_TXT=""
|
EXIT_TXT=""
|
||||||
|
|
||||||
# Adjustable color menu option
|
# Adjustable color menu option
|
||||||
if [[ "${_theme}" == "legacy" ]]; then
|
case "${_theme}" in
|
||||||
TITLES="${BOLD}${RED}"
|
"legacy" )
|
||||||
TEXT="${NORMAL}${CYAN}"
|
TITLES="${COLOR_BOLD}${COLOR_RED}"
|
||||||
NUMS="${BOLD}${YELLOW}"
|
TEXT="${COLOR_NORMAL}${COLOR_CYANL}"
|
||||||
HELP_TXT="${NORMAL}${YELLOW}"
|
NUMS="${COLOR_BOLD}${COLOR_YELLOW}"
|
||||||
EXIT_TXT="${BOLD}${RED}"
|
HELP_TXT="${COLOR_NORMAL}${COLOR_YELLOW}"
|
||||||
else
|
EXIT_TXT="${COLOR_BOLD}${COLOR_RED}"
|
||||||
TITLES="${BOLD}${CYAN}"
|
;;
|
||||||
TEXT="${NORMAL}${WHITE}"
|
"none" )
|
||||||
NUMS="${NORMAL}${BOLD}${WHITE}"
|
TITLES="${COLOR_BOLD}"
|
||||||
HELP_TXT="${NORMAL}${CYAN}"
|
TEXT="${COLOR_NORMAL}"
|
||||||
EXIT_TXT="${BOLD}${CYAN}"
|
NUMS="${COLOR_BOLD}"
|
||||||
fi
|
HELP_TXT="${COLOR_NORMAL}"
|
||||||
|
EXIT_TXT="${COLOR_BOLD}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
TITLES="${COLOR_BOLD}${COLOR_CYANL}"
|
||||||
|
TEXT="${COLOR_NORMAL}${COLOR_WHITE}"
|
||||||
|
NUMS="${COLOR_NORMAL}${COLOR_BOLD}${COLOR_WHITE}"
|
||||||
|
HELP_TXT="${COLOR_NORMAL}${COLOR_CYANL}"
|
||||||
|
EXIT_TXT="${COLOR_BOLD}${COLOR_CYANL}"
|
||||||
|
;;
|
||||||
|
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"
|
||||||
@@ -289,17 +470,28 @@ function showMenu() {
|
|||||||
printf %b "${NUMS} 21)${TEXT} Git commits per timezone by author\\n"
|
printf %b "${NUMS} 21)${TEXT} Git commits per timezone by author\\n"
|
||||||
printf %b "\\n${TITLES} Suggest:\\n"
|
printf %b "\\n${TITLES} Suggest:\\n"
|
||||||
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 "${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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filter_ignored_authors() {
|
||||||
|
if [[ -n "$_ignore_authors" ]]; then
|
||||||
|
grep -Ev "$_ignore_authors"
|
||||||
|
else
|
||||||
|
cat
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# FUNCTIONS FOR GENERATING STATS
|
# FUNCTIONS FOR GENERATING STATS
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# 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
|
||||||
@@ -331,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;
|
||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,8 +677,9 @@ function detailedGitStats() {
|
|||||||
# OUTS: None
|
# OUTS: None
|
||||||
################################################################################
|
################################################################################
|
||||||
function changelogs() {
|
function changelogs() {
|
||||||
local author="${1:-}"
|
|
||||||
local _author=""
|
local _author=""
|
||||||
|
local commits=""
|
||||||
|
local author="${1:-}"
|
||||||
local next=$(date +%F)
|
local next=$(date +%F)
|
||||||
|
|
||||||
if [[ -z "${author}" ]]; then
|
if [[ -z "${author}" ]]; then
|
||||||
@@ -435,12 +697,18 @@ function changelogs() {
|
|||||||
--date=short "${_author}" "$_since" "$_until" $_log_options $_pathspec \
|
--date=short "${_author}" "$_since" "$_until" $_log_options $_pathspec \
|
||||||
| sort -u -r | head -n $_limit \
|
| sort -u -r | head -n $_limit \
|
||||||
| while read DATE; do
|
| while read DATE; do
|
||||||
day=$(format_date "$DATE" "%A" "%Y-%m-%d")
|
commits=$(git -c log.showSignature=false log \
|
||||||
echo -e "\n[$DATE - $day]"
|
|
||||||
GIT_PAGER=cat git -c log.showSignature=false log \
|
|
||||||
--use-mailmap $_merges \
|
--use-mailmap $_merges \
|
||||||
--format=" * %s (%aN)" "${_author}" \
|
--format=" * %s (%aN)" "${_author}" \
|
||||||
--since==$(date -d "$DATE - 1 day" +"%Y-%m-%d") --until=$next
|
--since="$DATE 00:00:00" --until="$DATE 23:59:59" \
|
||||||
|
--date-order)
|
||||||
|
|
||||||
|
if [[ -n "$commits" ]]; then
|
||||||
|
echo -e "\n[$DATE]"
|
||||||
|
echo "$commits"
|
||||||
|
else
|
||||||
|
echo "No commits found on $DATE"
|
||||||
|
fi
|
||||||
next=$DATE
|
next=$DATE
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -486,7 +754,8 @@ function csvOutput() {
|
|||||||
# 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
|
||||||
@@ -499,7 +768,7 @@ function csvOutput() {
|
|||||||
printf "files_per,commits,commits_per,lines_changed,lines_changed_per\n"
|
printf "files_per,commits,commits_per,lines_changed,lines_changed_per\n"
|
||||||
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 | filter_ignored_authors | LC_ALL=C awk '
|
||||||
function printStats(author) {
|
function printStats(author) {
|
||||||
printf "%s,", author
|
printf "%s,", author
|
||||||
if(more["total"] > 0) {
|
if(more["total"] > 0) {
|
||||||
@@ -645,7 +914,7 @@ function jsonOutput() {
|
|||||||
"$propTag"' commit_notes%n%N%n'"$propTag"',%n "author": {%n'\
|
"$propTag"' commit_notes%n%N%n'"$propTag"',%n "author": {%n'\
|
||||||
"$propTag"' name%n%aN%n'"$propTag"',%n'\
|
"$propTag"' name%n%aN%n'"$propTag"',%n'\
|
||||||
"$propTag"' email%n%aE%n'"$propTag"',%n'\
|
"$propTag"' email%n%aE%n'"$propTag"',%n'\
|
||||||
' "date": "%aD"%n },%n "commiter": {%n'\
|
' "date": "%aD"%n },%n "committer": {%n'\
|
||||||
"$propTag"' name%n%cN%n'"$propTag"',%n'\
|
"$propTag"' name%n%cN%n'"$propTag"',%n'\
|
||||||
"$propTag"' email%n%cE%n'"$propTag"',%n'\
|
"$propTag"' email%n%cE%n'"$propTag"',%n'\
|
||||||
' "date": "%cD"%n }%n},' \
|
' "date": "%cD"%n }%n},' \
|
||||||
@@ -693,7 +962,7 @@ function branchesByDate() {
|
|||||||
function contributors() {
|
function contributors() {
|
||||||
optionPicked "All contributors (sorted by name):"
|
optionPicked "All contributors (sorted by name):"
|
||||||
git -c log.showSignature=false log --use-mailmap $_merges "$_since" "$_until" \
|
git -c log.showSignature=false log --use-mailmap $_merges "$_since" "$_until" \
|
||||||
--format='%aN' $_log_options $_pathspec | sort -u | cat -n
|
--format='%aN' $_log_options $_pathspec | filter_ignored_authors | sort -u | cat -n
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -709,7 +978,7 @@ function newContributors() {
|
|||||||
for c in $contributors; do
|
for c in $contributors; do
|
||||||
local firstCommit=$(git -c log.showSignature=false log --author="$c" \
|
local firstCommit=$(git -c log.showSignature=false log --author="$c" \
|
||||||
--reverse --use-mailmap $_merges "$_since" "$_until" \
|
--reverse --use-mailmap $_merges "$_since" "$_until" \
|
||||||
--format='%at' $_log_options $_pathspec | head -n 1)
|
--format='%at' $_log_options $_pathspec | filter_ignored_authors | head -n 1)
|
||||||
if [[ $firstCommit -ge $(date -d "$newDate" +%s) ]]; then
|
if [[ $firstCommit -ge $(date -d "$newDate" +%s) ]]; then
|
||||||
echo "$c"
|
echo "$c"
|
||||||
fi
|
fi
|
||||||
@@ -726,10 +995,10 @@ function commitsPerAuthor() {
|
|||||||
optionPicked "Git commits per author:"
|
optionPicked "Git commits per author:"
|
||||||
local authorCommits=$(git -c log.showSignature=false log --use-mailmap \
|
local authorCommits=$(git -c log.showSignature=false log --use-mailmap \
|
||||||
$_merges "$_since" "$_until" $_log_options \
|
$_merges "$_since" "$_until" $_log_options \
|
||||||
| grep -i Author: | cut -c9-)
|
| grep -i '^Author:' | cut -c9-)
|
||||||
local coAuthorCommits=$(git -c log.showSignature=false log --use-mailmap \
|
local coAuthorCommits=$(git -c log.showSignature=false log --use-mailmap \
|
||||||
$_merges "$_since" "$_until" $_log_options \
|
$_merges "$_since" "$_until" $_log_options \
|
||||||
| grep -i Co-Authored-by: | cut -c21-)
|
| grep -i '^ Co-Authored-by:' | cut -c21-)
|
||||||
|
|
||||||
if [[ -z "${coAuthorCommits}" ]]; then
|
if [[ -z "${coAuthorCommits}" ]]; then
|
||||||
allCommits="${authorCommits}"
|
allCommits="${authorCommits}"
|
||||||
@@ -761,6 +1030,47 @@ function commitsPerDay() {
|
|||||||
--date=short --format='%ad' $_log_options $_pathspec | sort | uniq -c
|
--date=short --format='%ad' $_log_options $_pathspec | sort | uniq -c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# DESC: Convert a timestamp to a date string to handle git's date formats
|
||||||
|
# ARGS: $1: Timestamp
|
||||||
|
# OUTS: Echoes a four-digit year
|
||||||
|
################################################################################
|
||||||
|
function parse_year() {
|
||||||
|
local date_str="$1"
|
||||||
|
local year
|
||||||
|
local timestamp
|
||||||
|
local default_git_date_regex
|
||||||
|
|
||||||
|
# Handle the raw UNIX timestamp format i.e. 1697375696 +0000
|
||||||
|
if [[ "$date_str" =~ ^[0-9]+(\ [+-][0-9]{4})?$ ]]; then
|
||||||
|
timestamp=$(echo "$date_str" | awk '{print $1}')
|
||||||
|
year=$(date -d "@$timestamp" '+%Y' 2>/dev/null)
|
||||||
|
else
|
||||||
|
# Default case can get funky. We need to create a clever regex to
|
||||||
|
# handle the default case which is like Mon Oct 15 12:34:56 2023 +0000
|
||||||
|
# Let's make this explicit for future devs to follow along.
|
||||||
|
default_git_date_regex='^' # Start from the beginning of the string
|
||||||
|
default_git_date_regex+='[A-Za-z]{3}\ ' # Day abbrev
|
||||||
|
default_git_date_regex+='[A-Za-z]{3}\ ' # Month abbrev
|
||||||
|
default_git_date_regex+='[0-9]{1,2}\ ' # Day of the month
|
||||||
|
default_git_date_regex+='[0-9]{2}:[0-9]{2}:[0-9]{2}\ ' # Time HH:MM:SS
|
||||||
|
default_git_date_regex+='[0-9]{4}\ ' # Year
|
||||||
|
default_git_date_regex+='[+-][0-9]{4}$' # Timezone offset
|
||||||
|
|
||||||
|
if [[ "$date_str" =~ $default_git_date_regex ]]; then
|
||||||
|
# Move the year before the time to match a format that Date can parse
|
||||||
|
date_str=$(echo "$date_str" | awk '{print $1, $2, $3, $5, $4, $6}')
|
||||||
|
elif [[ "$date_str" =~ ^[0-9]{1,2}/[0-9]{1,2}/[0-9]{2,4} ]]; then
|
||||||
|
# Handle DD/MM/YYYY format
|
||||||
|
date_str=$(echo "$date_str" | awk -F'/' '{print $2"/"$1"/"$3}')
|
||||||
|
fi
|
||||||
|
# Extract the final date
|
||||||
|
year=$(date -d "$date_str" '+%Y' 2>/dev/null)
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$year"
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# DESC: Displays a horizontal bar graph based on total commits per year
|
# DESC: Displays a horizontal bar graph based on total commits per year
|
||||||
# ARGS: None
|
# ARGS: None
|
||||||
@@ -769,30 +1079,39 @@ function commitsPerDay() {
|
|||||||
function commitsByYear() {
|
function commitsByYear() {
|
||||||
optionPicked "Git commits by year:"
|
optionPicked "Git commits by year:"
|
||||||
local year startYear endYear __since __until
|
local year startYear endYear __since __until
|
||||||
startYear=$(echo "$_since" | sed -E 's/^.* ([0-9]{4})( .*)?$/\1/')
|
|
||||||
endYear=$(echo "$_until" | sed -E 's/^.* ([0-9]{4})( .*)?$/\1/')
|
# Extract the date strings from $_since and $_until
|
||||||
|
since_date="${_since#--since=}"
|
||||||
|
until_date="${_until#--until=}"
|
||||||
|
|
||||||
|
# Grab the four digit year from $_since and $_until
|
||||||
|
startYear=$(parse_year "$since_date")
|
||||||
|
endYear=$(parse_year "$until_date")
|
||||||
|
|
||||||
echo -e "\tyear\tsum"
|
echo -e "\tyear\tsum"
|
||||||
for year in $(seq "$startYear" "$endYear")
|
# Add time strings to make these a touch more robust
|
||||||
|
for year in $(seq "$startYear" "$endYear");
|
||||||
do
|
do
|
||||||
if [ "$year" = "$startYear" ]
|
if [[ "$year" = "$startYear" ]]; then
|
||||||
then
|
|
||||||
__since=$_since
|
__since=$_since
|
||||||
__until="--until=$year-12-31"
|
__until="--until=$year-12-31 23:59:59"
|
||||||
elif [ "$year" = "$endYear" ]
|
elif [[ "$year" = "$endYear" ]]; then
|
||||||
then
|
__since="--since=$year-01-01 00:00:00"
|
||||||
__since="--since=$year-01-01"
|
|
||||||
__until=$_until
|
__until=$_until
|
||||||
else
|
else
|
||||||
__since="--since=$year-01-01"
|
__since="--since=$year-01-01 00:00:00"
|
||||||
__until="--until=$year-12-31"
|
__until="--until=$year-12-31 23:59:59"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -en "\t$year\t"
|
# Count commits directly using git rev-list instead of git log
|
||||||
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
|
commit_count=$(
|
||||||
"$__since" "$__until" $_log_options | grep -cE \
|
git rev-list --count $_merges \
|
||||||
" \w\w\w [0-9]{1,2} [0-9][0-9]:[0-9][0-9]:[0-9][0-9] $year " \
|
"$__since" "$__until" HEAD $_log_options
|
||||||
|| continue
|
)
|
||||||
|
echo -e "\t$year\t$commit_count"
|
||||||
|
# TODO: The bar graph can get funky when there are only a handful of
|
||||||
|
# commits. We can set a max length to try to fix this, but this is a
|
||||||
|
# bit of a problem across all the bar graphs.
|
||||||
done | awk '{
|
done | awk '{
|
||||||
count[$1] = $2
|
count[$1] = $2
|
||||||
total += $2
|
total += $2
|
||||||
@@ -801,8 +1120,7 @@ function commitsByYear() {
|
|||||||
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 );
|
||||||
@@ -834,8 +1152,7 @@ function commitsByMonth() {
|
|||||||
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 );
|
||||||
@@ -867,20 +1184,17 @@ 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"█"
|
||||||
@@ -915,8 +1229,7 @@ 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
|
||||||
@@ -925,8 +1238,7 @@ function commitsByHour() {
|
|||||||
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 );
|
||||||
@@ -970,7 +1282,7 @@ function suggestReviewers() {
|
|||||||
optionPicked "Suggested code reviewers (based on git history):"
|
optionPicked "Suggested code reviewers (based on git history):"
|
||||||
git -c log.showSignature=false log --use-mailmap $_merges "$_since" "$_until" \
|
git -c log.showSignature=false log --use-mailmap $_merges "$_since" "$_until" \
|
||||||
--pretty=%aN $_log_options $_pathspec | head -n 100 | sort | uniq -c \
|
--pretty=%aN $_log_options $_pathspec | head -n 100 | sort | uniq -c \
|
||||||
| sort -nr | LC_ALL=C awk '
|
| filter_ignored_authors | sort -nr | LC_ALL=C awk '
|
||||||
{ args[NR] = $0; }
|
{ args[NR] = $0; }
|
||||||
END {
|
END {
|
||||||
for (i = 1; i <= NR; ++i) {
|
for (i = 1; i <= NR; ++i) {
|
||||||
@@ -986,9 +1298,14 @@ function suggestReviewers() {
|
|||||||
checkUtils
|
checkUtils
|
||||||
|
|
||||||
# Check if we are currently in a git repo.
|
# Check if we are currently in a git repo.
|
||||||
git rev-parse --is-inside-work-tree > /dev/null
|
if ! git rev-parse --is-inside-work-tree > /dev/null; then
|
||||||
|
echo "ERROR: You need to be inside a git repo to parse stats!"
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
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
|
||||||
@@ -1074,20 +1391,30 @@ if [[ "$#" -eq 1 ]]; then
|
|||||||
read -r -p "Which author? " author
|
read -r -p "Which author? " author
|
||||||
done
|
done
|
||||||
commitsByTimezone "${author}";;
|
commitsByTimezone "${author}";;
|
||||||
|
# CALENDAR OPTIONS
|
||||||
|
-k|--commits-calendar-by-author)
|
||||||
|
author="${_GIT_AUTHOR:-}"
|
||||||
|
while [[ -z "${author}" ]]; do
|
||||||
|
read -r -p "Which author? " author
|
||||||
|
done
|
||||||
|
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
|
||||||
|
clear
|
||||||
|
showMenu
|
||||||
|
|
||||||
while [[ "${opt}" != "" ]]; do
|
while [[ "${opt}" != "" ]]; do
|
||||||
clear
|
clear
|
||||||
case "${opt}" in
|
case "${opt}" in
|
||||||
1) detailedGitStats; showMenu;;
|
1) detailedGitStats; showMenu;;
|
||||||
@@ -1131,7 +1458,6 @@ while [[ "${opt}" != "" ]]; do
|
|||||||
11) newDate=""
|
11) newDate=""
|
||||||
while [[ -z "${newDate}" ]]; do
|
while [[ -z "${newDate}" ]]; do
|
||||||
read -r -p "Since what date? (e.g. '2023-04-13', '13 April 2023', 'last Thursday') " newDate
|
read -r -p "Since what date? (e.g. '2023-04-13', '13 April 2023', 'last Thursday') " newDate
|
||||||
# Test if the date provide is valid and try again if it isn't.
|
|
||||||
if ! date -d "${newDate}" +%s > /dev/null 2>&1; then
|
if ! date -d "${newDate}" +%s > /dev/null 2>&1; then
|
||||||
newDate=""
|
newDate=""
|
||||||
fi
|
fi
|
||||||
@@ -1160,7 +1486,14 @@ while [[ "${opt}" != "" ]]; do
|
|||||||
done
|
done
|
||||||
commitsByTimezone "${author}"; showMenu;;
|
commitsByTimezone "${author}"; showMenu;;
|
||||||
22) suggestReviewers; showMenu;;
|
22) suggestReviewers; showMenu;;
|
||||||
|
23) author=""
|
||||||
|
while [[ -z "${author}" ]]; do
|
||||||
|
read -r -p "Which author? " author
|
||||||
|
done
|
||||||
|
commitsCalendarByAuthor "${author}"; showMenu;;
|
||||||
|
24) commitsHeatmap; showMenu;;
|
||||||
q|"\n") exit;;
|
q|"\n") exit;;
|
||||||
*) clear; optionPicked "Pick an option from the menu"; showMenu;;
|
*) clear; optionPicked "Pick an option from the menu"; showMenu;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.TH git-quick-stats "1" "April 2024" "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.
|
||||||
@@ -19,6 +19,10 @@ This program allows you to see detailed information about a git repository.
|
|||||||
.PP
|
.PP
|
||||||
.SH GENERATE OPTIONS
|
.SH GENERATE OPTIONS
|
||||||
.PP
|
.PP
|
||||||
|
\fB\-h\fR, \-?, \fB\-\-help\fR
|
||||||
|
.IP
|
||||||
|
display this help text in the terminal
|
||||||
|
.PP
|
||||||
\fB\-T\fR, \fB\-\-detailed\-git\-stats\fR
|
\fB\-T\fR, \fB\-\-detailed\-git\-stats\fR
|
||||||
.IP
|
.IP
|
||||||
give a detailed list of git stats
|
give a detailed list of git stats
|
||||||
@@ -124,6 +128,11 @@ displays a list of commits per timezone
|
|||||||
.IP
|
.IP
|
||||||
displays a list of commits per timezone by author
|
displays a list of commits per timezone by author
|
||||||
.HP
|
.HP
|
||||||
|
.PP
|
||||||
|
\fB\-\-activity\-calendar\fR
|
||||||
|
.IP
|
||||||
|
displays a calendar-style grid of commit activity per day-of-week and month for a selected author.
|
||||||
|
.HP
|
||||||
.SH SUGGEST OPTIONS
|
.SH SUGGEST OPTIONS
|
||||||
.PP
|
.PP
|
||||||
\fB\-r\fR, \fB\-\-suggest\-reviewers\fR
|
\fB\-r\fR, \fB\-\-suggest\-reviewers\fR
|
||||||
@@ -131,9 +140,12 @@ displays a list of commits per timezone by author
|
|||||||
show the best people to contact to review code
|
show the best people to contact to review code
|
||||||
.HP
|
.HP
|
||||||
.PP
|
.PP
|
||||||
\fB\-h\fR, \-?, \fB\-\-help\fR
|
.SH CALENDAR OPTIONS
|
||||||
.IP
|
.PP
|
||||||
display this help text in the terminal
|
\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.
|
||||||
|
.PP
|
||||||
|
.PP
|
||||||
|
\fB\-H\fR, \fB\-\-commits\-heatmap\fR shows a heatmap of commits per day per hour for the last 30 days
|
||||||
.PP
|
.PP
|
||||||
.SH ADDITIONAL USAGE
|
.SH ADDITIONAL USAGE
|
||||||
You can set _GIT_SINCE and _GIT_UNTIL to limit the git time log, example:
|
You can set _GIT_SINCE and _GIT_UNTIL to limit the git time log, example:
|
||||||
@@ -160,12 +172,35 @@ You can also set _GIT_MERGE_VIEW to only show merge commits, example:
|
|||||||
.PP
|
.PP
|
||||||
.B export _GIT_MERGE_VIEW="exclusive"
|
.B export _GIT_MERGE_VIEW="exclusive"
|
||||||
.PP
|
.PP
|
||||||
You can switch to the legacy color scheme, 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
|
||||||
|
.B export _GIT_SORT_BY="name-asc"
|
||||||
|
.PP
|
||||||
|
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 _MENU_THEME=legacy
|
.B export _MENU_THEME=legacy
|
||||||
.PP
|
.PP
|
||||||
|
or
|
||||||
|
.B export _MENU_THEME=none
|
||||||
|
.PP
|
||||||
You can set _GIT_BRANCH to set the branch of the stats, example:
|
You can set _GIT_BRANCH to set the branch of the stats, example:
|
||||||
.PP
|
.PP
|
||||||
.B export _GIT_BRANCH="master"
|
.B export _GIT_BRANCH="master"
|
||||||
|
.PP
|
||||||
|
You can set _GIT_IGNORE_AUTHORS to filter out specific authors, example:
|
||||||
|
.PP
|
||||||
|
.B export _GIT_IGNORE_AUTHORS="(author@examle.com|username)"
|
||||||
|
.PP
|
||||||
|
You can set _GIT_DAYS to set the number of days for the heatmap, example:
|
||||||
|
.PP
|
||||||
|
.B export _GIT_DAYS=30"
|
||||||
.
|
.
|
||||||
.fi
|
.fi
|
||||||
|
|
||||||
|
.PP
|
||||||
|
.SH SEE ALSO
|
||||||
|
.BR git (1)
|
||||||
|
.PP
|
||||||
|
Project homepage:
|
||||||
|
.UR https://github.com/git-quick-stats/git-quick-stats
|
||||||
|
.UE
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -92,17 +98,24 @@ ADDITIONAL USAGE
|
|||||||
ex: export _GIT_MERGE_VIEW=enable
|
ex: export _GIT_MERGE_VIEW=enable
|
||||||
You can also set _GIT_MERGE_VIEW to only show merge commits
|
You can also set _GIT_MERGE_VIEW to only show merge commits
|
||||||
ex: export _GIT_MERGE_VIEW=exclusive
|
ex: export _GIT_MERGE_VIEW=exclusive
|
||||||
You can set _MENU_THEME to display the legacy color scheme
|
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\".
|
||||||
ex: export _MENU_THEME=legacy
|
ex: export _MENU_THEME=legacy
|
||||||
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
|
||||||
|
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"
|
||||||
|
|||||||
Reference in New Issue
Block a user