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.0.tar.gz (22.2 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.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: oh_my_gitstats-0.3.0.tar.gz
  • Upload date:
  • Size: 22.2 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.0.tar.gz
Algorithm Hash digest
SHA256 3f488fdf2ed1befa8a9ad34ff3d5928ecd620033789fd69aaf18370a5da66207
MD5 98e8851caad7ec7ddf4bdc2b92b5e3c1
BLAKE2b-256 741994daddfd654f1a5a9be1c7635b38ac6d3ca48891f07bf93c616e3999290b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oh_my_gitstats-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 21.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8304a2cf1fc8d90c55bc236a2fda05f7a279dcc5de7c739c10dbec90ea773f35
MD5 5509b7b27de344b0534c46b237bdf13f
BLAKE2b-256 6ad9bc42063af9ef631cc3c8abebbaffa4e4d409dedc06174d4c85a9c6a13f2e

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