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, editable date range inputs + presets (30D / 90D / 6M / 1Y / ALL), and dynamic legend filtering by selected range
  • ๐Ÿ—“๏ธ Calendar Heatmaps โ€” Visualize commit activity with year-based filtering; GitHub-style green gradient, perfectly square day cells
  • ๐ŸŽฏ Aggregated & Individual Views โ€” See combined or per-repo statistics in a strict 2-column Swiss grid
  • ๐Ÿ”ฌ Per-Repo Detail Modal โ€” Click any repo card to open a large line chart + heatmap + meta info (Commits / Lines / First / Last / Local / Remote / Action)
  • ๐Ÿšฆ Local + Remote Signal Lamps โ€” Each sync status is decomposed into two independent traffic-light indicators (green / yellow / red / gray) for working-tree state and remote-tracking state
  • ๐ŸŽจ Swiss International Style โ€” Pure white background, Inter/Helvetica stack, 12-column grid, horizontal rules instead of shadows, MDI icons (jsDelivr)
  • ๐Ÿ“‚ 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 is built with a Swiss International Style design system (pure white, Inter/Helvetica, strict 12-column grid, MDI icons via jsDelivr). It contains:

  1. ๐Ÿ“ˆ Line Chart (01 / Trend) โ€” Metric selector (Lines Changed / Commit Count) + granularity selector (Day / Week / Month) + editable date range bar with two <input type="date"> (or <input type="month"> when granularity is month) and preset buttons (30D / 90D / 6M / 1Y / ALL). Range drives and is driven by ECharts dataZoom; legend items are dynamically filtered to only show repositories with commits inside the selected range.

  2. ๐Ÿ—“๏ธ Aggregate Heatmap (02 / Aggregate) โ€” Combined activity across all repos with year selector (All Years / specific year). GitHub-style green gradient, fixed-square day cells, height auto-adjusts when switching between single-year and multi-year ranges.

  3. ๐Ÿ“Š Individual Heatmaps (03 / Repositories) โ€” 2-column grid of per-repo cards. Each card shows repo name, monospace path, Local + Remote signal lamps (small colored circles labeled L / R, with traffic-light colors green / yellow / red / gray), and a Continue / Archived button with MDI icon (vscode://file/ URI). Click any card to open the Detail Modal with a large per-repo line chart (default granularity Day), large heatmap, and a 7-cell meta grid (Commits / Lines / First / Last / Local / Remote / Action). Closeable via ร— button, backdrop click, or Escape key.

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, decomposed at render time into two independent Local + Remote signal lamps (the stored JSON value is a single enum):

sync_status Local Remote
โœ… synced ๐ŸŸข Clean ๐ŸŸข Synced
โœ๏ธ local_changes ๐ŸŸก Dirty ๐ŸŸข Synced
โฌ‡๏ธ remote_ahead ๐ŸŸข Clean ๐ŸŸก Ahead
โš ๏ธ diverged ๐ŸŸก Dirty ๐ŸŸก Ahead
๐Ÿ”’ local_only_clean ๐ŸŸข Clean โšช None
๐Ÿ”ง local_only_dirty ๐ŸŸก Dirty โšช None
โš ๏ธ network_error_clean ๐ŸŸข Clean ๐Ÿ”ด Error
โš ๏ธ network_error_dirty ๐ŸŸก Dirty ๐Ÿ”ด Error

is_archived โ€” Whether the repo is archived on GitHub (set by --check). Values: true, false, or null (not checked or check failed). 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.2.tar.gz (35.1 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.2-py3-none-any.whl (33.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: oh_my_gitstats-0.3.2.tar.gz
  • Upload date:
  • Size: 35.1 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.2.tar.gz
Algorithm Hash digest
SHA256 891f67c34e210e80d1ece64d66aba51b224245e81b84f962ed3dbe3b5182a1b8
MD5 a3401f78363c0a53a3de0cef011665a1
BLAKE2b-256 6f37fc715980c4a1bcef3cb1aa1a84aaffe20ee864f5e8f2387fe34608e462fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oh_my_gitstats-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 33.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 714265be0dcabafdb52cdf798f1afab3a84999685c2dacd0b14acd37ad943627
MD5 52b8fc55bfdf404b1cae5330caefb8dc
BLAKE2b-256 b7e289d0d5844288a4660a607c0b55b901e626b5c9996c899194c5c0166c7a00

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