Compare commits

...

72 Commits

Author SHA1 Message Date
arzzen
a813846c9f Merge pull request #151 from YDX-2147483647/patch-1
fix: Ubuntu does not support `date -j`
2023-10-17 06:26:33 +02:00
Y.D.X
22bf354da4 fix: Ubuntu does not support date -j
This is required for changelogs.

Resolves #147
2023-10-09 17:29:08 +08:00
arzzen
0fea0323a4 Merge pull request #150 from riderius/master 2023-10-04 20:50:24 +02:00
riderius
4fcf8f5fef test: fix a typo in the 1st test
Signed-off-by: riderius <riderius.help@gmail.com>
2023-10-04 18:27:38 +03:00
arzzen
374aa2ef72 Merge pull request #145 from s-okita/master
Add stats by author per weekday functionality
2023-06-23 15:01:04 +02:00
s-okita
33dca7f3ed Update git-quick-stats.1 2023-06-23 17:07:18 +09:00
s-okita
2ecb296442 Merge branch 'arzzen:master' into master 2023-06-07 02:42:22 +09:00
arzzen
428d25d0ef Merge pull request #144 from jgtoriginal/master
add day name to date
2023-06-06 14:58:29 +02:00
s-okita
c3110e985e Add stats by author per weekday functionality
* Added the ability to see git stats both per weekday, as well as
  by author per weekday. It should respect all global options.

* Updated tests, README.md, and man page to reflect the new changes
2023-06-06 19:36:47 +09:00
jgtoriginal
ebbeb34837 add day name to date
when grouping by author -L, I found it hard to read YYYY-MM-DD, so added day name to that.
2023-05-25 01:14:05 +01:00
Tom Ice
71d414eb4a Merge pull request #137 from pyxide/fix/json-format-output
fix: json format output with multiline content
2022-07-11 16:09:01 -04:00
pyxide
d8346210a4 fix: json format output with multiline content 2022-07-11 19:15:07 +02:00
Tom Ice
b85760e8b9 Merge pull request #136 from dotmpe/master
Misc. fixes on filtering, added commits-by-year
2022-02-26 21:01:26 -05:00
B. van Berkum
07ad3b57a7 Updated screenshot URLs after PR#136 changes 2022-02-24 04:54:27 +01:00
B. van Berkum
dec1c4e103 Add --commits-by-year; put 'since' at first commit
- Added commits-by-year graph/statistics.
- Made 'since' use first reachable commit, instead of GIT epoch (May
  2005). To avoid empty bars in the new 'Commits by years' graph.

- Removed start-/end-year filter: on -by-weekday, -hour and -month. Instead
  made each `grep` look for its date tag fixed in a more specific sequence
  so as to not match commit message.

  Was giving problems if a since/until date-span larger than one year was given
  (ie. #135, #130, #123).

  Maybe should look at removing commit message from log listing entirely.
  Not sure why `grep -E "($startYear|$endYear)"` was ever introduced yet.

- Made tests run properly, updated test with usage output.
  Added a test-case with LC_TIME=POSIX.
2022-02-19 00:01:07 +01:00
Lukáš Mešťan
2a0294941f Update README.md 2021-08-19 09:16:37 +02:00
Lukáš Mešťan
22f1b3563d Merge pull request #133 from tomice/master
Add stat by author per timezone functionality
2021-06-15 13:52:05 +02:00
Tom Ice
628b31ffd8 Convert README.md inline HTML to pure Markdown
* The README.md contained inline HTML for the contributors, backers,
  and sponsors section. This technically works when the README.md is
  rendered within a webpage, but other Markdown readers, such as those
  that are built into GUIs, may or may not render them correctly.
  This changes those inline HTML hyperlinks to pure Markdown as
  specified by Markdown Lint rule MD033. For more info, see:

  https://github.com/DavidAnson/markdownlint/blob/v0.23.1/doc/Rules.md#md033

* Fixes some other small whitespace and inconsistency issues
2021-06-12 11:47:56 -04:00
Tom Ice
1e5723d7a2 Add stats by author per timezone functionality
* Added the ability to see git stats both per timezone, as well as
  by author per timezone. It should respect all global options.

* Adjusted the non-interactive menu as it was missed during the
  reorganization effort

* Updated tests, README.md, man page, and screenshots to reflect the
  new changes

* Resolves #128
2021-06-11 17:35:56 -04:00
Tom Ice
0c1749a560 Reorganize code to be consistent with the menu
* Before, we had various functions in a different order from the
  interactive menu in the code base. This changes our ordering of
  the functions and aligns the interactive menu, man pages, README.md,
  and code base so that they are all following the same paradigm.

  Also fixes some minor missing keywords
2021-06-11 16:11:26 -04:00
Tom Ice
ecab54c630 Fix some whitespace and other internal formatting
* Did some minor clean up of white space to try to adhere to the
  classic 80 characters per line standard that is typically found
  in shell code. It isn't perfect, but it's getting us closer.

* Added some extra notes and todos for adjustments that can be made
  and potential future work for others to jump in on.
2021-06-11 13:26:34 -04:00
Lukáš Mešťan
7219205696 Merge pull request #131 from treussart/export-csv
Export CSV of detailedGitStats
2021-05-20 07:46:54 +02:00
Tom Ice
dd3c97816e Update README.md to display new functionality
* With pull request #131, we add new functionality for both interactive and non-interactive modes.
  This change updates the README.md to reflect our new menu option for outputting the stats in CSV
2021-05-20 00:17:23 -04:00
Matthieu Treussart
d2b273eead Export CSV of detailedGitStats 2021-05-20 05:25:09 +02:00
Lukáš Mešťan
5b08bb0b52 Merge pull request #129 from treussart/add_git_branch_option
Add git branch option
2021-05-19 08:36:00 +02:00
Matthieu Treussart
08d1a5a6e3 Set git branch in options 2021-05-18 21:51:40 +02:00
Lukáš Mešťan
f5c2b82f02 Merge pull request #127 from pawaer/fix/issue126
Replaced grep commit by grep with regex including git sha hash
2021-04-29 08:36:34 +02:00
Pawaer
bf29c19cf5 Replaced grep commit by grep with regex including git sha hash
myDailyStats() used grep commit to detect count of commits. This
also increases the count by mentioning commit in the commit
message.

Therefore a grep with regex is used that expects a 40 digit/char
SHA1 hash after the word commit.
2021-04-24 21:50:30 +02:00
Lukáš Mešťan
c6cb74a5e0 Merge pull request #125 from arzzen/fix/issue-123
fix shortlog filter
2021-04-02 19:16:02 +02:00
arzzen
3f0befcd07 fix shortlog filter 2021-04-02 13:34:46 +02:00
Lukáš Mešťan
292876846d Merge pull request #124 from tomice/master
Fix escape sequences when outputting to non-TTYs
2021-03-31 17:31:28 +02:00
Tom Ice
e70c288225 Fix escape sequences when outputting to non-TTYs
* When performing actions such as redirecting the stats to a file,
  the terminal escape sequences for handling colors gets added
  to the top message in the text file. While running commands such
  as sed can fix this, it is inconvenient for users wishing to redirect
  or pipe the stats in a clean way.

  Attempting to use test -t yielded some unexpected results, as well
  as extra logic for handling a non-tty case, so for now, we are
  simply removing the colors from the message so it defaults to
  standard terminal colors and formatting

Fixes #122
2021-03-31 10:33:25 -04:00
Lukáš Mešťan
4d2621b084 Update LICENSE
bump year
2021-02-24 08:14:12 +01:00
Lukáš Mešťan
2318d42765 Merge pull request #121 from tomice/master
Change default date to be when git was first invented
2021-02-05 17:02:54 +01:00
Tom Ice
ef74d79102 Change default date to be when git was first invented
* The current default date is set to UNIX Epoch time. However, it seems
  some people are possibly having issues with date/time formats within
  their OSes. This commit attempts to fix issue #115 when the default
  date may be too old and cause no output to show
2021-01-29 19:31:29 -05:00
Lukáš Mešťan
82f8690285 Merge pull request #120 from vutny/fix-tests-assert-contains
test: fix assert_contains and its invocation
2020-12-19 19:55:30 +01:00
Denys Havrysh
0f641ea0e6 test: fix assert_contains and its invocation 2020-12-18 17:27:46 +02:00
Lukáš Mešťan
6c7bd4fddf Merge pull request #118 from vutny/fix-decimal-percent-view
fix: correct localized decimal percent numbers
2020-12-18 08:22:55 +01:00
Denys Havrysh
9f9617b88b fix: correct localized decimal percent numbers 2020-12-16 17:28:13 +02:00
Lukáš Mešťan
8cea653d6c Update FUNDING.yml 2020-09-09 12:52:08 +02:00
Lukáš Mešťan
efa004122e Update README.md 2020-08-25 18:07:35 +02:00
Lukáš Mešťan
0534327006 Merge pull request #114 from SuperSandro2000/patch-1
Mention apt install method
2020-08-14 10:19:35 +02:00
Sandro
a113dc306f Mention which releases have the package 2020-08-14 10:01:56 +02:00
Sandro
0fc2fe956b Mention apt install method 2020-08-12 22:51:14 +02:00
Lukáš Mešťan
1efe3133dc Merge pull request #113 from mcpcpc/master
usage: remove non-POSIX compliant features
2020-07-26 15:19:37 +02:00
Michael Czigler
3fd0ee2453 usage: remove non-POSIX compliant features 2020-07-23 09:33:37 -04:00
Lukáš Mešťan
a4f19c9e54 Merge pull request #112 from mcpcpc/usage
usage: remove non-POSIX compliant features
2020-07-23 13:48:48 +02:00
Michael Czigler
cd38c40fe8 usage: remove non-POSIX compliant features 2020-07-22 11:46:58 -04:00
Lukáš Mešťan
3283122a38 Merge pull request #109 from mcpcpc/master
checkUtils: remove non-POSIX compliant features
2020-07-22 17:18:59 +02:00
Michael Czigler
920b95c042 squash commit, remove non-POSIX features in checkUtils 2020-07-21 09:07:44 -04:00
Lukáš Mešťan
810ffcff54 update homebrew badge url 2020-07-14 19:05:50 +02:00
Lukáš Mešťan
f9df7ee5e2 Merge pull request #106 from arzzen/task/log-options
Ability to use options for git log command
2020-07-10 18:18:58 +02:00
arzzen
e31fc931c8 add git log options to myDailyStats 2020-07-10 18:13:01 +02:00
arzzen
0655814800 fix test 2020-07-10 08:02:28 +02:00
arzzen
1eb8c53f09 ability to use options for git log command 2020-07-09 09:21:25 +02:00
Lukáš Mešťan
3b2f26e85d Merge pull request #103 from tomice/master
Fix folder excluding pathspec bug #102
2020-06-28 12:59:29 +02:00
Tom Ice
93aa829eae Fix folder excluding pathspec bug #102
* There was an issue with quoting in the pathspec variable where
  the variable would get mangled when being passed to different
  parameters during git operations. This change fixes that.

Fixes #102
2020-06-27 20:02:50 -04:00
Lukáš Mešťan
1a11540b67 Merge pull request #101 from tomice/master
Fix divide by zero error during lines changed calc
2020-05-11 16:15:30 +02:00
Tom Ice
6692ec8aa3 Hotfix for non-GNU awk on macOS 2020-05-10 15:10:30 -04:00
Tom Ice
63eba9f1b8 Fix divide by zero error during lines changed calc
* A new feature was implemented to show percentages when displaying
  detailed stats (menu options 1 and 2, or options -T and -R).
  However, the calculation during "lines changed" may cause an error
  within awk stating it cannot divide by zero as there is no check
  to see if the divisor is larger than zero.

  This commit attempts to fix that issue, albeit admittedly not in
  the most elegant way...

Fixes #100
2020-05-10 14:57:09 -04:00
Lukáš Mešťan
228e67f879 Merge pull request #99 from tomice/master
Fix issue with env vars not respecting spaces
2020-05-07 10:29:58 +02:00
Tom Ice
891e2277ad Add info on how to use experimental JSON feature
* The JSON output feature was not originally explained well and needed
  some additional information on how it worked. Extra info on how to use
  this feature, as well as reminding people that this is a beta feature,
  was added to help the users when trying out this option

Fixes #96
2020-05-01 17:57:19 -04:00
Tom Ice
cc87b3046f Fix issue with env vars not respecting spaces
* If a space existed within _GIT_SINCE, _GIT_UNTIL, or _GIT_PATHSPEC,
  the shell would split the variable at the first space it saw because
  the variables were not quoted.

  If you were to simply quote the variables, then a null variable would
  get inserted into git's log, and it would cause an error.

  This change adds default values to these variables at all times so
  the variables are always assigned to something that git understands.

Fixes #95
2020-05-01 15:29:33 -04:00
Lukáš Mešťan
7aea224e21 Merge pull request #98 from novadiscovery/97-new-lines-as-percent
add percentage for new lines as well
2020-05-01 11:37:49 +02:00
frederic.cogny
c37492bb4c chore(git-quick-stats): add tab instead of space for nicer alignment between percentage counts 2020-05-01 01:03:21 +02:00
frederic.cogny
c258e34afe feat(git-quick-stats): add percentage for new lines as well 2020-05-01 00:36:10 +02:00
Lukáš Mešťan
9e18cf35d4 Merge pull request #94 from arzzen/patch-issue-91
Update commitsByWeekday sorting
2020-02-18 11:31:35 +01:00
Lukáš Mešťan
24ae67ae57 update commitsByWeekday sorting
Fix inconsistent sum sorting in by-weekday, #91
2020-02-14 09:34:46 +01:00
Lukáš Mešťan
ed0e3cbb6b Merge pull request #93 from tomice/master
Fixing OS X compatibility with merge feature
2020-02-13 09:42:06 +01:00
Tom Ice
46a771138e Fixing OS X compatibility with merge feature
* OS X utilizes an older version of GNU Bash. As such, certain features
  such as lowercase expansion can fail. This commit removes the Bash 4.0
  syntax in favor of a POSIX syntax with awk.
2020-02-11 08:25:44 -05:00
Lukáš Mešťan
9f54b87ed5 Update FUNDING.yml 2020-02-05 09:33:07 +00:00
Lukáš Mešťan
246076f5f6 Bump year 2020-01-20 08:00:06 +00:00
10 changed files with 1182 additions and 568 deletions

2
.github/FUNDING.yml vendored
View File

@@ -2,3 +2,5 @@
github: [arzzen]
open_collective: git-quick-stats
ko_fi: lukasmestan
custom: ['https://lukasmestan.com/thanks/']

3
.gitignore vendored
View File

@@ -8,3 +8,6 @@
.Trash*
**/*~
nbproject/*
/tests/test-git/.git/
#/tests/test-git/*
!/tests/test-git/resetgit

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019 Lukáš Mešťan
Copyright (c) 2021 Lukáš Mešťan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -3,6 +3,7 @@ _INSTDIR ?= $(DESTDIR)$(PREFIX)
BINDIR ?= $(_INSTDIR)/bin
MANDIR ?= $(_INSTDIR)/share/man
TASK_DONE = echo -e "\n✓ $@ done\n"
SHELL := $(shell which bash)
.PHONY: test

163
README.md
View File

@@ -1,11 +1,12 @@
# GIT quick statistics [![Backers on Open Collective](https://opencollective.com/git-quick-stats/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/git-quick-stats/sponsors/badge.svg)](#sponsors) [![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) [![Travis](https://api.travis-ci.org/arzzen/git-quick-stats.svg?branch=master)](https://travis-ci.org/arzzen/git-quick-stats) [![Homebrew package](https://repology.org/badge/version-for-repo/homebrew/git-quick-stats.svg)](http://braumeister.org/formula/git-quick-stats) [![Linuxbrew package](https://repology.org/badge/version-for-repo/linuxbrew/git-quick-stats.svg)](https://repology.org/metapackage/git-quick-stats/packages)
# GIT quick statistics [![Backers on Open Collective](https://opencollective.com/git-quick-stats/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/git-quick-stats/sponsors/badge.svg)](#sponsors) [![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) [![Travis](https://api.travis-ci.org/arzzen/git-quick-stats.svg?branch=master)](https://travis-ci.org/arzzen/git-quick-stats) [![Homebrew package](https://repology.org/badge/version-for-repo/homebrew/git-quick-stats.svg)](https://formulae.brew.sh/formula/git-quick-stats#default) [![Linuxbrew package](https://repology.org/badge/version-for-repo/linuxbrew/git-quick-stats.svg)](https://repology.org/metapackage/git-quick-stats/packages)
> `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 dont think there is a single person alive who knows them all. Probably not even [Linus Torvalds](https://github.com/torvalds) himself :).
![mainMenuScreenshot](https://user-images.githubusercontent.com/8818630/58364013-61e53800-7e7b-11e9-87f9-790d6744fbd5.png)
![mainMenuScreenshot](https://user-images.githubusercontent.com/8818630/154823670-f42a111b-45f4-47fc-aea7-80059827c8e6.png)
## Table of Contents
@@ -18,6 +19,7 @@
* [**Command-line arguments**](#command-line-arguments)
* [**Git log since and until**](#git-log-since-and-until)
* [**Git log limit**](#git-log-limit)
* [**Git log options**](#git-log-options)
* [**Git pathspec**](#git-pathspec)
* [**Git merge view strategy**](#git-merge-view-strategy)
* [**Color themes**](#color-themes)
@@ -52,15 +54,15 @@
## Screenshots
![commitsByWeekdayScreenshot](https://user-images.githubusercontent.com/8818630/58364011-61e53800-7e7b-11e9-9417-16cbb241ac2e.png)
![commitsByWeekdayScreenshot](https://user-images.githubusercontent.com/8818630/154823677-e34ca867-ae61-4755-bf89-c877f809c591.png)
![commitsByHourScreenshot](https://user-images.githubusercontent.com/8818630/58364010-61e53800-7e7b-11e9-8711-a40b50aebf52.png)
![commitsByHourScreenshot](https://user-images.githubusercontent.com/8818630/154823679-bdadc26c-c644-4a01-b625-85e330f85d41.png)
## Usage
### Interactive
git-quick-stats has a built-in interactive menu that can be executed as such:
`git-quick-stats` has a built-in interactive menu that can be executed as such:
```bash
git-quick-stats
@@ -91,39 +93,54 @@ git quick-stats <optional-command-to-execute-directly>
Possible arguments in short and long form:
```bash
-r, --suggest-reviewers
show the best people to contact to review code
-T, --detailed-git-stats
GENERATE OPTIONS
-T, --detailed-git-stats
give a detailed list of git stats
-R, --git-stats-by-branch
-R, --git-stats-by-branch
see detailed list of git stats by branch
-d, --commits-per-day
displays a list of commits per day
-m, --commits-by-month
displays a list of commits per month
-w, --commits-by-weekday
displays a list of commits per weekday
-o, --commits-by-hour
displays a list of commits per hour
-A, --commits-by-author-by-hour
displays a list of commits per hour by author
-a, --commits-per-author
displays a list of commits per author
-S, --my-daily-stats
see your current daily stats
-C, --contributors
see a list of everyone who contributed to the repo
-b, --branch-tree
show an ASCII graph of the git repo branch history
-D, --branches-by-date
show branches by date
-c, --changelogs
-c, --changelogs
see changelogs
-L, --changelogs-by-author
-L, --changelogs-by-author
see changelogs by author
-j, --json-output
-S, --my-daily-stats
see your current daily stats
-V, --csv-output-by-branch
output daily stats by branch in CSV format
-j, --json-output
save git log as a JSON formatted file to a specified area
-h, -?, --help
LIST OPTIONS
-b, --branch-tree
show an ASCII graph of the git repo branch history
-D, --branches-by-date
show branches by date
-C, --contributors
see a list of everyone who contributed to the repo
-a, --commits-per-author
displays a list of commits per author
-d, --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
displays a list of commits per month
-w, --commits-by-weekday
displays a list of commits per weekday
-W, --commits-by-author-by-weekday
displays a list of commits per weekday by author
-o, --commits-by-hour
displays a list of commits per hour
-A, --commits-by-author-by-hour
displays a list of commits per hour by author
-z, --commits-by-timezone
displays a list of commits per timezone
-Z, --commits-by-author-by-timezone
displays a list of commits per timezone by author
SUGGEST OPTIONS
-r, --suggest-reviewers
show the best people to contact to review code
-h, -?, --help
display this help text in the terminal
```
@@ -146,6 +163,14 @@ You can set variable `_GIT_LIMIT` for limited output. It will affect the "change
export _GIT_LIMIT=20
```
### Git log options
You can set `_GIT_LOG_OPTIONS` for [git log options](https://git-scm.com/docs/git-log#_options):
```bash
export _GIT_LOG_OPTIONS="--ignore-all-space --ignore-blank-lines"
```
### Git pathspec
You can exclude a directory from the stats by using [pathspec](https://git-scm.com/docs/gitglossary#gitglossary-aiddefpathspecapathspec)
@@ -169,18 +194,34 @@ export _GIT_MERGE_VIEW="enable"
export _GIT_MERGE_VIEW="exclusive"
```
### Git branch
You can set the variable `_GIT_BRANCH` to set the branch of the stats. Works with commands `--git-stats-by-branch` and `--csv-output-by-branch`.
```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`
```bash
export _MENU_THEME=legacy
export _MENU_THEME="legacy"
```
![legacyThemeScreenshot](https://user-images.githubusercontent.com/8818630/58364012-61e53800-7e7b-11e9-910a-aaff836260eb.png)
![legacyThemeScreenshot](https://user-images.githubusercontent.com/8818630/154823711-3dd0c268-f3cb-42e5-9094-0eb8e45d1761.png)
## Installation
### Debian and Ubuntu
If you are on at least Debian Bullseye or Ubuntu Focal you can use apt for installation:
```bash
apt install git-quick-stats
```
### UNIX and Linux
```bash
@@ -228,7 +269,24 @@ You can use the Docker image provided:
## System requirements
* An OS with a Bash shell
* Tools we use: awk ; basename ; cat ; column ; echo ; git ; grep ; head ; seq ; sort ; tput ; tr ; uniq ; wc
* Tools we use:
```bash
awk
basename
cat
column
echo
git
grep
head
printf
seq
sort
tput
tr
uniq
```
### Dependencies
@@ -240,6 +298,11 @@ You can use the Docker image provided:
*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?
*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))
## Contribution
Want to contribute? Great! First, read this page.
@@ -286,25 +349,29 @@ MIT see [LICENSE][] for the full license text.
## Contributors
This project exists thanks to all the people who contribute.
<a href="https://github.com/arzzen/git-quick-stats/graphs/contributors"><img src="https://opencollective.com/git-quick-stats/contributors.svg?width=890&button=false" /></a>
[![contributors](https://opencollective.com/git-quick-stats/contributors.svg?width=890&button=false)](https://github.com/arzzen/git-quick-stats/graphs/contributors)
### Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/git-quick-stats#backer)]
<a href="https://opencollective.com/git-quick-stats#backers" target="_blank"><img src="https://opencollective.com/git-quick-stats/backers.svg?width=890"></a>
[![backers](https://opencollective.com/git-quick-stats/backers.svg?width=890)](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)]
<a href="https://opencollective.com/git-quick-stats/sponsor/0/website" target="_blank"><img src="https://opencollective.com/git-quick-stats/sponsor/0/avatar.svg?v=1"></a>
<a href="https://opencollective.com/git-quick-stats/sponsor/1/website" target="_blank"><img src="https://opencollective.com/git-quick-stats/sponsor/1/avatar.svg"></a>
<a href="https://opencollective.com/git-quick-stats/sponsor/2/website" target="_blank"><img src="https://opencollective.com/git-quick-stats/sponsor/2/avatar.svg"></a>
<a href="https://opencollective.com/git-quick-stats/sponsor/3/website" target="_blank"><img src="https://opencollective.com/git-quick-stats/sponsor/3/avatar.svg"></a>
<a href="https://opencollective.com/git-quick-stats/sponsor/4/website" target="_blank"><img src="https://opencollective.com/git-quick-stats/sponsor/4/avatar.svg"></a>
<a href="https://opencollective.com/git-quick-stats/sponsor/5/website" target="_blank"><img src="https://opencollective.com/git-quick-stats/sponsor/5/avatar.svg"></a>
<a href="https://opencollective.com/git-quick-stats/sponsor/6/website" target="_blank"><img src="https://opencollective.com/git-quick-stats/sponsor/6/avatar.svg"></a>
<a href="https://opencollective.com/git-quick-stats/sponsor/7/website" target="_blank"><img src="https://opencollective.com/git-quick-stats/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/git-quick-stats/sponsor/8/website" target="_blank"><img src="https://opencollective.com/git-quick-stats/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/git-quick-stats/sponsor/9/website" target="_blank"><img src="https://opencollective.com/git-quick-stats/sponsor/9/avatar.svg"></a>
[![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)
[![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)
[![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)
[![sponsor7](https://opencollective.com/git-quick-stats/sponsor/7/avatar.svg)](https://opencollective.com/git-quick-stats/sponsor/7/website)
[![sponsor8](https://opencollective.com/git-quick-stats/sponsor/8/avatar.svg)](https://opencollective.com/git-quick-stats/sponsor/8/website)
[![sponsor9](https://opencollective.com/git-quick-stats/sponsor/9/avatar.svg)](https://opencollective.com/git-quick-stats/sponsor/9/website)
[![61999966](https://user-images.githubusercontent.com/6382002/130024560-65bb49a6-c7e9-48f9-8427-a29d8ff2a3db.png)](https://quaestor.com/?utm_source=github&utm_category=sponsor)

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
.TH git-quick-stats "1" "January 2020" "git-quick-stats" "User Commands"
.TH git-quick-stats "1" "June 2021" "git-quick-stats" "User Commands"
.SH NAME
.B git\-quick\-stats
\- Simple and efficient way to access various stats in a git repository.
@@ -17,12 +17,7 @@ and files. Extracting this information is not always trivial, mostly because
of a gadzillion options to a gadzillion git commands.
This program allows you to see detailed information about a git repository.
.PP
.SH OPTIONS
.HP
\fB\-r\fR, \fB\-\-suggest\-reviewers\fR
.IP
show the best people to contact to review code
.HP
.SH GENERATE OPTIONS
.PP
\fB\-T\fR, \fB\-\-detailed\-git\-stats\fR
.IP
@@ -34,56 +29,6 @@ give a detailed list of git stats
see detailed list of git stats by branch
.HP
.PP
\fB\-d\fR, \fB\-\-commits\-per\-day\fR
.IP
displays a list of commits per day
.HP
.PP
\fB\-m\fR, \fB\-\-commits\-by\-month\fR
.IP
displays a list of commits per month
.HP
.PP
\fB\-w\fR, \fB\-\-commits\-by\-weekday\fR
.IP
displays a list of commits per weekday
.HP
.PP
\fB\-o\fR, \fB\-\-commits\-by\-hour\fR
.IP
displays a list of commits per hour
.HP
.PP
\fB\-A\fR, \fB\-\-commits\-by\-author\-by\-hour\fR
.IP
displays a list of commits per hour by author
.HP
.PP
\fB\-a\fR, \fB\-\-commits\-per\-author\fR
.IP
displays a list of commits per author
.HP
.PP
\fB\-S\fR, \fB\-\-my\-daily\-stats\fR
.IP
see your current daily stats
.HP
.PP
\fB\-C\fR, \fB\-\-contributors\fR
.IP
see a list of everyone who contributed to the repo
.HP
.PP
\fB\-b\fR, \fB\-\-branch\-tree\fR
.IP
show an ASCII graph of the git repo branch history
.HP
.PP
\fB\-D\fR, \fB\-\-branches\-by\-date\fR
.IP
show branches by date
.HP
.PP
\fB\-c\fR, \fB\-\-changelogs\fR
.IP
see changelogs
@@ -94,10 +39,92 @@ see changelogs
see changelogs by author
.HP
.PP
\fB\-S\fR, \fB\-\-my\-daily\-stats\fR
.IP
see your current daily stats
.HP
.PP
\fB\-V\fR, \fB\-\-csv\-output\-by\-branch\fR
.IP
output daily stats by branch in CSV format
.HP
.PP
\fB\-j\fR, \fB\-\-json\-output\fR
.IP
save git log as a JSON formatted file to a specified area
.HP
.SH LIST OPTIONS
.PP
\fB\-b\fR, \fB\-\-branch\-tree\fR
.IP
show an ASCII graph of the git repo branch history
.HP
.PP
\fB\-D\fR, \fB\-\-branches\-by\-date\fR
.IP
show branches by date
.HP
.PP
\fB\-C\fR, \fB\-\-contributors\fR
.IP
see a list of everyone who contributed to the repo
.HP
.PP
\fB\-a\fR, \fB\-\-commits\-per\-author\fR
.IP
displays a list of commits per author
.HP
.PP
\fB\-d\fR, \fB\-\-commits\-per\-day\fR
.IP
displays a list of commits per day
.HP
.PP
\fB\-m\fR, \fB\-\-commits\-by\-month\fR
.IP
displays a list of commits per month
.HP
.PP
\fB\-Y\fR, \fB\-\-commits\-by\-year\fR
.IP
displays a list of commits per year
.HP
.PP
\fB\-w\fR, \fB\-\-commits\-by\-weekday\fR
.IP
displays a list of commits per weekday
.HP
.PP
\fB\-W\fR, \fB\-\-commits\-by\author\-by\-weekday\fR
.IP
displays a list of commits per weekday by author
.HP
.PP
\fB\-o\fR, \fB\-\-commits\-by\-hour\fR
.IP
displays a list of commits per hour
.HP
.PP
\fB\-A\fR, \fB\-\-commits\-by\-author\-by\-hour\fR
.IP
displays a list of commits per hour by author
.HP
.PP
\fB\-z\fR, \fB\-\-commits\-by\-timezone\fR
.IP
displays a list of commits per timezone
.HP
.PP
\fB\-Z\fR, \fB\-\-commits\-by\-author\-by\-timezone\fR
.IP
displays a list of commits per timezone by author
.HP
.SH SUGGEST OPTIONS
.PP
\fB\-r\fR, \fB\-\-suggest\-reviewers\fR
.IP
show the best people to contact to review code
.HP
.PP
\fB\-h\fR, \-?, \fB\-\-help\fR
.IP
@@ -112,6 +139,10 @@ You can set _GIT_LIMIT for limited output log, example:
.PP
.B export _GIT_LIMIT=20
.PP
You can set _GIT_LOG_OPTIONS for git log options, example:
.PP
.B export _GIT_LOG_OPTIONS="--ignore-all-space --ignore-blank-lines"
.PP
You can exclude directories or files from the stats by using pathspec, example:
.PP
.B export _GIT_PATHSPEC=':!pattern'
@@ -127,6 +158,9 @@ You can also set _GIT_MERGE_VIEW to only show merge commits, example:
You can switch to the legacy color scheme, example:
.PP
.B export _MENU_THEME=legacy
.PP
You can set _GIT_BRANCH to set the branch of the stats, example:
.PP
.B export _GIT_BRANCH="master"
.
.fi

View File

@@ -17,12 +17,16 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -o nounset
export DISCOVERONLY=${DISCOVERONLY:-}
export DEBUG=${DEBUG:-}
export STOP=${STOP:-}
export INVARIANT=${INVARIANT:-}
export CONTINUE=${CONTINUE:-}
GREP=${GREP:-grep}
args="$(getopt -n "$0" -l \
verbose,help,stop,discover,invariant,continue vhxdic $*)" \
|| exit -1
@@ -101,7 +105,7 @@ assert_end() {
assert() {
# assert <command> <expected stdout> [stdin]
(( tests_ran++ )) || :
[[ -z "$DISCOVERONLY" ]] || return
[[ -z "$DISCOVERONLY" ]] || return 0
expected=$(echo -ne "${2:-}")
result="$(eval 2>/dev/null $1 <<< ${3:-})" || true
if [[ "$result" == "$expected" ]]; then
@@ -111,13 +115,13 @@ assert() {
result="$(sed -e :a -e '$!N;s/\n/\\n/;ta' <<< "$result")"
[[ -z "$result" ]] && result="nothing" || result="\"$result\""
[[ -z "$2" ]] && expected="nothing" || expected="\"$2\""
_assert_fail "expected $expected${_indent}got $result" "$1" "$3"
_assert_fail "expected $expected${_indent}got $result" "$1" "${3:-}"
}
assert_raises() {
# assert_raises <command> <expected code> [stdin]
(( tests_ran++ )) || :
[[ -z "$DISCOVERONLY" ]] || return
[[ -z "$DISCOVERONLY" ]] || return 0
status=0
(eval $1 <<< ${3:-}) > /dev/null 2>&1 || status=$?
expected=${2:-0}
@@ -125,14 +129,19 @@ assert_raises() {
[[ -z "$DEBUG" ]] || echo -n .
return
fi
_assert_fail "program terminated with code $status instead of $expected" "$1" "$3"
_assert_fail "program terminated with code $status instead of $expected" "$1" "${3:-}"
}
assert_success() {
# assert_success <command>
assert_raises "$1" 0
}
# _assert_with_grep <grep modifiers> <command> <expected output...>
_assert_with_grep() {
local grep_modifier="$1"
local output="$($2)"
local exitcode="$4" || 0
local exitcode=0
shift 2
while [ $# != 0 ]; do

View File

@@ -3,16 +3,106 @@
. tests/assert.sh -v
src="./git-quick-stats"
assert "$src fail" "Invalid argument\n\nNAME\n git-quick-stats - Simple and efficient way to access various stats in a git repo\n\nSYNOPSIS\n For non-interactive mode: git-quick-stats [OPTIONS]\n For interactive mode: git-quick-stats\n\nDESCRIPTION\n Any git repository contains tons of information about commits, contributors,\n and files. Extracting this information is not always trivial, mostly because\n of a gadzillion options to a gadzillion git commands.\n\n This program allows you to see detailed information about a git repository.\n\nOPTIONS\n -r, --suggest-reviewers\n show the best people to contact to review code\n -T, --detailed-git-stats\n give a detailed list of git stats\n -R, --git-stats-by-branch\n see detailed list of git stats by branch\n -d, --commits-per-day\n displays a list of commits per day\n -m, --commits-by-month\n displays a list of commits per month\n -w, --commits-by-weekday\n displays a list of commits per weekday\n -o, --commits-by-hour\n displays a list of commits per hour\n -A, --commits-by-author-by-hour\n displays a list of commits per hour by author\n -a, --commits-per-author\n displays a list of commits per author\n -S, --my-daily-stats\n see your current daily stats\n -C, --contributors\n see a list of everyone who contributed to the repo\n -b, --branch-tree\n show an ASCII graph of the git repo branch history\n -D, --branches-by-date\n show branches by date\n -c, --changelogs\n see changelogs\n -L, --changelogs-by-author\n see changelogs by author\n -j, --json-output\n save git log as a JSON formatted file to a specified area\n -h, -?, --help\n display this help text in the terminal\n\nADDITIONAL USAGE\n You can set _GIT_SINCE and _GIT_UNTIL to limit the git time log\n ex: export _GIT_SINCE=\"2017-01-20\"\n You can set _GIT_LIMIT for limited output log\n ex: export _GIT_LIMIT=20\n You can exclude directories or files from the stats by using pathspec\n ex: export _GIT_PATHSPEC=':!pattern'\n You can set _GIT_MERGE_VIEW to view merge commits with normal commits\n ex: export _GIT_MERGE_VIEW=enable\n You can also set _GIT_MERGE_VIEW to only show merge commits\n ex: export _GIT_MERGE_VIEW=exclusive\n You can set _MENU_THEME to display the legacy color scheme\n ex: export _MENU_THEME=legacy"
assert "$src fail" "Invalid argument
NAME
git-quick-stats - Simple and efficient way to access various stats in a git repo
SYNOPSIS
For non-interactive mode: git-quick-stats [OPTIONS]
For interactive mode: git-quick-stats
DESCRIPTION
Any git repository contains tons of information about commits, contributors,
and files. Extracting this information is not always trivial, mostly because
of a gadzillion options to a gadzillion git commands.
This program allows you to see detailed information about a git repository.
GENERATE OPTIONS
-T, --detailed-git-stats
give a detailed list of git stats
-R, --git-stats-by-branch
see detailed list of git stats by branch
-c, --changelogs
see changelogs
-L, --changelogs-by-author
see changelogs by author
-S, --my-daily-stats
see your current daily stats
-V, --csv-output-by-branch
output daily stats by branch in CSV format
-j, --json-output
save git log as a JSON formatted file to a specified area
LIST OPTIONS
-b, --branch-tree
show an ASCII graph of the git repo branch history
-D, --branches-by-date
show branches by date
-C, --contributors
see a list of everyone who contributed to the repo
-a, --commits-per-author
displays a list of commits per author
-d, --commits-per-day
displays a list of commits per day
-m, --commits-by-month
displays a list of commits per month
-Y, --commits-by-year
displays a list of commits per year
-w, --commits-by-weekday
displays a list of commits per weekday
-W, --commits-by-author-by-weekday
displays a list of commits per weekday by author
-o, --commits-by-hour
displays a list of commits per hour
-A, --commits-by-author-by-hour
displays a list of commits per hour by author
-z, --commits-by-timezone
displays a list of commits per timezone
-Z, --commits-by-author-by-timezone
displays a list of commits per timezone by author
SUGGEST OPTIONS
-r, --suggest-reviewers
show the best people to contact to review code
-h, -?, --help
display this help text in the terminal
ADDITIONAL USAGE
You can set _GIT_SINCE and _GIT_UNTIL to limit the git time log
ex: export _GIT_SINCE=\"2017-01-20\"
You can set _GIT_LIMIT for limited output log
ex: export _GIT_LIMIT=20
You can set _GIT_LOG_OPTIONS for git log options
ex: export _GIT_LOG_OPTIONS=\"--ignore-all-space --ignore-blank-lines\"
You can exclude directories or files from the stats by using pathspec
ex: export _GIT_PATHSPEC=':!pattern'
You can set _GIT_MERGE_VIEW to view merge commits with normal commits
ex: export _GIT_MERGE_VIEW=enable
You can also set _GIT_MERGE_VIEW to only show merge commits
ex: export _GIT_MERGE_VIEW=exclusive
You can set _MENU_THEME to display the legacy color scheme
ex: export _MENU_THEME=legacy
You can set _GIT_BRANCH to set the branch of the stats
ex: export _GIT_BRANCH=master"
assert_raises "$src fail" 1
assert_contains "$src --suggest-reviewers" "Suggested code reviewers (based on git history)" 127
assert_raises "$src --suggest-reviewers" 0
assert_contains "$src --suggest-reviewers" "Suggested code reviewers (based on git history)"
assert_success "$src --suggest-reviewers"
assert_contains "$src --detailed-git-stats" "Contribution stats" 127
assert_raises "$src --detailed-git-stats" 0
assert_contains "$src --detailed-git-stats" "Contribution stats"
assert_success "$src --detailed-git-stats"
assert_contains "$src --commits-per-day" "Git commits per date" 127
assert_raises "$src --commits-per-day" 0
assert_contains "$src --commits-per-day" "Git commits per date"
assert_success "$src --commits-per-day"
assert_startswith "$src --commits-by-year" "Git commits by year"
assert_success "$src --commits-by-year"
export LC_TIME=POSIX
assert_startswith "$src --commits-by-year" "Git commits by year"
assert_success "$src --commits-by-year"
assert_end

17
tests/test-git/resetgit Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
# Initialises a new local Git repo for test purpose.
if test -d ../test-git/.git; then rm -Rf ../test-git/.git; fi
#mkdir test-git
cd ../test-git
git init
git config user.name "$(printf %s 'Test Git,\nfor test purpose')"
git config user.email "TestGit\o/@example.org"
#printf '\n[user]\nname = test-git\nemail = test-git@example.org\n'> .git/config
printf 'test-git\n========\n' > README.md
git add README.md
git commit -m 'added readme (o\w/o)' -m 'in markdown, no \r\n, only \n' -m 'a very "simple" readme'
testChars="$(printf 'tab [%b] form feed [%b] line feed [%b] carriage return [%b]' '\x09' '\x0C' '\x0A' '\x0D')"
#printf '# testChars [%s]\n' "$testChars">&2
git notes add -m 'Some notes' -m 'out of ascii: été au cœur' -m "$testChars"
git log