🐍📊 Git Py Stats is a Python-powered version of Git Quick Stats that provides a streamlined and cross-platform way to access various statistics in your git repository.
MIT License
Git Py Stats is a Python-based fork inspired by git-quick-stats. It offers a similar set of git statistics and reports, but it's built entirely using Python 3, providing improved cross-platform compatibility and ease of maintenance.
While git-quick-stats
is a fantastic tool, it has some limitations due to its
reliance on Bash and external utilities:
git-quick-stats
can have issues runningtput
, column
, and grep
, which may not begit-quick-stats
has the ability to exportGit Py Stats tackles these challenges by leveraging Python's standard library,
guaranteeing that it incorporates code vetted by the Python team and operates
smoothly on any platform with Python 3 installed. It stays true to the essence
of git-quick-stats
by ensuring that no dependencies beyond Python 3 and git
are ever required.
Git Py Stats aims to maintain feature parity with git-quick-stats
with
features such as:
and more in both interactive and non-interactive modes.
While this project aims to be feature-complete and 1:1 with git-quick-stats
,
there may be instances where this version differs from the base project.
The following is a list of differences that this project will maintain compared
to the parent project:
git-py-stats -L "John Doe"
insteadgit_daily_stats.csv
git_log.json
Python 3.8+: Git Py Stats requires Python 3.8 or higher installed on your system. While it may work with older versions, there is no guarantee as it is currently untested with versions below 3.8. You can check your Python version with:
python --version
If your python
is symlinked to Python 2, you can use
pyenv
to switch between Python versions.
Git:
Git should be installed and available in your system's PATH
.
Install Using pip:
pip install git-py-stats
That's it! You can now use git-py-stats
anywhere on your system
while inside of a git repo!
If you experience conflicts with other packages,
try using venv
setup.py
If you prefer using setup.py
directly:
Clone the Repository:
git clone https://github.com/tomice/git-py-stats.git
cd git-py-stats
Install the Package:
python setup.py install
That's it! You can now use git-py-stats
anywhere on your system
while inside of a git repo! If you don't have admin permissions,
you can use the --user
flag at the end of the command to install
this locally.
Clone the Repository:
git clone https://github.com/tomice/git-py-stats.git
cd git-py-stats
Set PYTHONPATH:
Set the root of git-py-stats
to be prefixed to your PYTHONPATH
:
export PYTHONPATH=$(pwd):$PYTHONPATH
That's it! You can now use git-py-stats
anywhere on your system
while inside of a git repo, albeit with a slight modification.
Commands will need to be done in the following manner:
python -m git_py_stats.main --help
This will tell Python to run the git_py_stats.main
module directly.
This method is usually best for devs who want to help contribute to the
project without going through the install process a normal end user would.
You can run Git Py Stats in both interactive and non-interactive modes:
Simply run the tool without any arguments to enter the interactive menu:
git-py-stats
Run the tool with specific command-line options for direct output. For example:
Detailed Git Stats:
git-py-stats -T
Git Stats by Branch:
git-py-stats -R master
List Contributors:
git-py-stats -C
For a full list of available options, run:
git-py-stats --help
It is possible for git-py-stats
to read shell environment variables just like
git-quick-stats
does. As it aims to maintain 1:1 compatibility, all of the
same arguments work the same as the parent project.
You can set the variables _GIT_SINCE
and/or _GIT_UNTIL
before running
git-py-stats
to limit the git log.
These work similar to git's built-in --since
and --until
log options.
export _GIT_SINCE="2017-01-20"
export _GIT_UNTIL="2017-01-22"
Once set, run git-py-stats
as normal. Note that this affects all stats that
parse the git log history until unset.
You can set variable _GIT_LIMIT
for limited output.
It will affect the "changelogs" and "branch tree" options.
The default limit is 10
.
export _GIT_LIMIT=20
You can set _GIT_LOG_OPTIONS
for
git log options:
export _GIT_LOG_OPTIONS="--ignore-all-space --ignore-blank-lines"
You can exclude a directory from the stats by using pathspec.
export _GIT_PATHSPEC=':!directory'
You can also exclude files from the stats. Note that it works with any alphanumeric, glob, or regex that git respects.
export _GIT_PATHSPEC=':!package-lock.json'
You can set the variable _GIT_MERGE_VIEW
to enable merge commits to be part
of the stats by setting _GIT_MERGE_VIEW
to enable
. You can also choose to
only show merge commits by setting _GIT_MERGE_VIEW
to exclusive
.
Default is to not show merge commits.
These work similar to git's built-in --merges
and --no-merges
log options.
export _GIT_MERGE_VIEW="enable"
export _GIT_MERGE_VIEW="exclusive"
You can set the variable _GIT_BRANCH
to set the branch of the stats.
Works with commands --git-stats-by-branch
and --csv-output-by-branch
.
export _GIT_BRANCH="master"
You can change to the legacy color scheme by toggling the variable
_MENU_THEME
between default
and legacy
export _MENU_THEME="legacy"
We welcome contributions of all kinds! Please read our CONTRIBUTING.md guide to learn how to get involved.
To ensure a positive and inclusive community, please follow our Code of Conduct during your interactions.
This project is licensed under the MIT License. See the LICENSE file for more details.
Tom Ice