Skip to main content

Git repository commit statistics collector and visualizer

Project description

๐Ÿ“Š oh-my-gitstats

ไธญๆ–‡ | English

A Python CLI tool for collecting git commit statistics and visualizing them as interactive HTML charts.

Line Chart Heatmap

โœจ Features

  • ๐Ÿ” Batch Collection โ€” Scan multiple git repositories recursively
  • โšก Incremental Sync โ€” Only fetch new commits since last collection
  • ๐Ÿš€ One-Step Workflow โ€” gitstats auto does everything in one command
  • ๐Ÿ“ˆ Line Charts โ€” Track changes over time with metric & granularity switching
  • ๐Ÿ—“๏ธ Calendar Heatmaps โ€” Visualize commit activity with year-based filtering
  • ๐ŸŽฏ Aggregated & Individual Views โ€” See combined or per-repo statistics
  • ๐Ÿ“‚ VS Code Integration โ€” Open repo folders directly from the HTML report

๐Ÿš€ Installation

pip install oh-my-gitstats

Or install from source:

git clone https://github.com/amomorning/oh-my-gitstats.git
cd oh-my-gitstats
pip install -e .

โšก Quick Start

First time, collect from each project directory (paths are auto-recorded in config):

cd ~/projects && gitstats collect .
cd ~/work && gitstats collect .

After that, one command does collect โ†’ sync โ†’ visualize โ†’ open browser:

gitstats auto

You can also manually edit the config file to add directories:

# The config file is auto-created at:
~/.gitstats/settings.json
{
  "collect_paths": [
    "/home/user/projects",
    "/home/user/work"
  ]
}

Options:

Option Description
-q, --quiet Suppress output messages
--check Check GitHub archive status (requires network; set GITHUB_TOKEN for private repos)
--no-open Do not open the HTML file in browser after generation

๐Ÿ“– Commands

collect โ€” Collect Commit Data

Scan a directory for git repositories and export to JSON:

gitstats collect /path/to/repos
Option Description
-o, --output Directory to save JSON files (default: ~/.gitstats/data)
-q, --quiet Suppress output messages
--skip Skip repos that already have a JSON file
--check Check GitHub archive status

sync โ€” Incremental Sync

Update existing JSON files with only new commits โ€” much faster than re-collecting:

gitstats sync
Option Description
-q, --quiet Suppress output messages
--check Check GitHub archive status

Typical workflow with multiple directories:

# One-time: collect from different locations
gitstats collect /path/to/work-projects
gitstats collect /path/to/personal-projects --skip

# Later: update all at once
gitstats sync

visualize โ€” Generate Visualization

Create an interactive HTML file from collected data:

gitstats visualize
Option Description
-o, --output HTML file path (default: ~/.gitstats/stats.html)

Granularity and metric can be switched dynamically in the generated HTML โ€” no need to regenerate.

โš™๏ธ Configuration

Config file at ~/.gitstats/settings.json (auto-created on first run):

{
  "data_dir": "~/.gitstats/data",
  "output_html": "~/.gitstats/stats.html",
  "collect_paths": []
}
Field Description
data_dir Where JSON files are stored
output_html Where HTML visualization is generated
collect_paths Directories for gitstats auto to scan (auto-populated when you run collect)

๐Ÿ”‘ GitHub Token (Optional)

--check queries the GitHub API to check archive status. Without authentication, only public repositories can be checked (rate limit: 60 requests/hour).

If GITHUB_TOKEN is not set, a warning will be printed when using --check.

To check private repositories, set the GITHUB_TOKEN environment variable:

Linux / macOS

export GITHUB_TOKEN=ghp_your_token_here
gitstats sync --check

Windows (PowerShell)

Set for current session:

$env:GITHUB_TOKEN="ghp_your_token_here"
gitstats sync --check

Set permanently: Settings โ†’ System โ†’ About โ†’ Advanced system settings โ†’ Environment Variables โ†’ User variables โ†’ New

How to get a token

  1. Go to GitHub โ†’ Settings โ†’ Developer settings โ†’ Personal access tokens โ†’ Tokens (classic)
  2. Click Generate new token (classic)
  3. Give it a name (e.g. oh-my-gitstats)
  4. Under Select scopes, no additional scopes are needed for public repos
  5. To access private repositories, check the repo scope
  6. Click Generate token and copy the value (starts with ghp_)

Note: Use Tokens (classic), not Fine-grained tokens. With a token, the rate limit increases to 5,000 requests/hour.

๐Ÿ“ Output

The generated HTML contains:

  1. ๐Ÿ“ˆ Line Chart โ€” Changes over time with metric selector (Lines Changed / Commit Count) and granularity selector (Day/Week/Month). Click legend to toggle projects.

  2. ๐Ÿ—“๏ธ Aggregate Heatmap โ€” Combined activity across all repos with year selector (All Years / specific year).

  3. ๐Ÿ“Š Individual Heatmaps โ€” Per-repository calendar views in a responsive grid, each with sync status indicator and a "Continue" / "Archived" button to open in VS Code.

Individual Heatmaps

๐Ÿ“‹ JSON Format

Each repository generates a JSON file (~/.gitstats/data/{repo_name}.json):

{
  "repo_name": "my-project",
  "repo_path": "/absolute/path/to/my-project",
  "last_commit_hash": "a1b2c3d4...",
  "sync_status": "synced",
  "is_archived": false,
  "commits": [
    {
      "timestamp": "2024-01-15T10:30:00",
      "additions": 45,
      "deletions": 12
    }
  ]
}

last_commit_hash โ€” HEAD hash at collection time. During sync, repos with a matching hash are skipped instantly.

sync_status โ€” Sync state with remote:

Status Description
โœ… synced In sync with remote
โœ๏ธ local_changes Local has uncommitted changes, remote is up-to-date
โฌ‡๏ธ remote_ahead Local is clean, but remote has new commits
โš ๏ธ diverged Local has uncommitted changes and remote has new commits
๐Ÿ”’ local_only_clean No remote configured, local is clean
๐Ÿ”ง local_only_dirty No remote configured, local has uncommitted changes
โš ๏ธ network_error_clean Remote exists but fetch failed, local is clean
โš ๏ธ network_error_dirty Remote exists but fetch failed, local has uncommitted changes

is_archived โ€” Whether the repo is archived on GitHub (set by --check). Values: true, false, or null (not checked). Archived repos show a grayed-out "Archived" button.

๐Ÿ”ง Requirements

  • Python 3.9+
  • click, gitpython, pyecharts, jinja2, requests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oh_my_gitstats-0.3.1.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oh_my_gitstats-0.3.1-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file oh_my_gitstats-0.3.1.tar.gz.

File metadata

  • Download URL: oh_my_gitstats-0.3.1.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for oh_my_gitstats-0.3.1.tar.gz
Algorithm Hash digest
SHA256 62924eaec9c02020eff798cb3c87335d5674a419470a76e85479cce1d1be75ff
MD5 df8bdbe29b9965fc809a9444202e6699
BLAKE2b-256 a01943e899b09ccdd0f8ebd5f21ef048ba72c3ab10f3ca03f3b233429ed66cc0

See more details on using hashes here.

File details

Details for the file oh_my_gitstats-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: oh_my_gitstats-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for oh_my_gitstats-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9674b72a854b3f2c058c5357a423e6828f2c97494e8ea3461e33215ae6baa575
MD5 9d90ebc623e9725acc80a5020d772d64
BLAKE2b-256 634c4a8b3a7f23a5b99b301db3bb3dea38d72a3093c82eb598cc9d9e03920eb0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page