Skip to main content

A powerful Git history visualizer and hygiene linter with CI gating.

Project description

Git Graphable

CI License: MIT Coverage Hygiene

A powerful Python tool to convert Git commit history into beautiful, interactive flowcharts using the graphable library. Supporting Mermaid, D2, Graphviz, and HTML.

Git Plugin Support

When installed in your PATH, you can use this as a native Git plugin:

git graphable analyze .

🚀 Live Interactive Demo

Check out the tool in action with our Live Interactive Demos. Explore different hygiene scenarios and toggle overlays in real-time.

Features

  • Multi-Engine Support: Export to Mermaid (.mmd), D2 (.d2), Graphviz (.dot), or HTML (.html).
  • Automatic Visualization: Generates and opens an image (PNG) automatically if no output is specified.
  • Advanced Highlighting: Visualize author patterns, topological distance, and specific merge paths.
  • VCS Integration: Highlight commits based on pull request/merge request status using gh (GitHub) or glab (GitLab) CLIs.
  • Hygiene Analysis: Automatically detect WIP commits, direct pushes to protected branches, squashed PRs, back-merges, and contributor silos.
  • Issue Tracker Integration: Connect to Jira, GitHub Issues, GitLab Issues, or custom scripts to highlight status desyncs.
  • Security First: Configuration trust mechanism ensures custom scripts only run from trusted sources (use --trust to authorize local configs).
  • Dynamic Badges: Host live Shields.io badges for Git Hygiene and Code Coverage on GitHub Pages.

Installation

# Using uv (recommended)
uv sync --all-extras

Usage

For a complete reference of all command-line options, see the USAGE.md file. For visual demonstrations of all features, see examples/EXAMPLES.md.

# Basic usage (opens a Mermaid image)
uv run git-graphable analyze .

# Highlight PR status (requires gh CLI)
uv run git-graphable analyze . --highlight-pr-status

# Specify an engine and output file
uv run git-graphable analyze https://github.com/TheTrueSCU/graphable/ --engine d2 -o graph.svg

# Initialize a default configuration file
uv run git-graphable init

# Simplify the graph (only show branches/tags)
uv run git-graphable analyze . --simplify

GitHub Action

Git Graphable can be easily integrated into your GitHub workflows to automatically generate hygiene reports on every push or pull request.

jobs:
  git-hygiene:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0 # Required to see full history

      - name: Generate Git Graph Reports
        uses: TheTrueSCU/git-graphable@v0.6.0
        with:
          production_branch: 'main'
          output_dir: 'reports'

Inputs

The following inputs are available for the git-graphable action:

  • path
    • Description: Path to the git repository
    • Required: false
    • Default: '.'
  • production_branch
    • Description: The main production branch (e.g. main, master)
    • Required: false
    • Default: 'main'
  • issue_engine
    • Description: Issue tracker engine (github or jira)
    • Required: false
  • github_token
    • Description: GitHub token for issue integration
    • Required: false
    • Default: ${{ github.token }}
  • output_dir
    • Description: Directory to save the generated reports
    • Required: false
    • Default: 'git-graph-reports'

The action generates a simplified Mermaid summary (for quick review) and a full interactive HTML graph (for deep-dive auditing), uploading them as workflow artifacts.

Highlighting Options

Git Graphable provides several ways to highlight commits and relationships. Multiple options can be combined to layer information.

Option Target Effect Conflicts With
--highlight-authors Fill Unique color per author PR Status, Distance, Stale
--highlight-pr-status Fill/Stroke Color by PR/MR state (Merged=Purple, Open=Green) Authors, Distance, Stale
--highlight-distance-from Fill Blue gradient fading by distance Authors, PR Status, Stale
--highlight-stale Fill Gradient white to red by age Authors, PR Status, Distance
--highlight-path Edge Thick Orange edge connecting nodes None
--highlight-wip Stroke/Fill Yellow highlight for WIP/TODO commits None
--highlight-critical Stroke Thick Red Solid outline None
--highlight-diverging-from Stroke Orange Dashed outline None
--highlight-orphans Stroke Grey Dashed outline None
--highlight-long-running Stroke/Edge Purple outline and thick Purple edge None
--highlight-direct-pushes Stroke Thick Red Dashed outline None
--highlight-squashed Stroke/Edge Grey Solid outline and dashed Grey logical merge edge None
--highlight-back-merges Stroke Orange Dashed outline None
--highlight-silos Stroke Blue Solid outline None
--highlight-issue-inconsistencies Label Adds [ISSUE-DESYNC] label None
--highlight-release-inconsistencies Label Adds [NOT-RELEASED] label None
--highlight-collaboration-gaps Label Adds [COLLAB-GAP] label None
--highlight-longevity-mismatch Label Adds [LONGEVITY] label None

For a full reference of the default visual styles and how to customize them, see STYLING.md.

Advanced Examples

Hygiene Analysis

Identify problematic patterns like direct pushes to main, messy WIP commits, back-merges from main, or contributor silos:

uv run git-graphable analyze . --highlight-direct-pushes --highlight-wip --highlight-squashed --highlight-back-merges --highlight-silos

PR Status Highlighting

View the current state of all PRs in your repository graph:

uv run git-graphable analyze . --highlight-pr-status

Divergence Analysis (Hygiene)

Highlight commits that exist in main but are missing from your feature branches:

uv run git-graphable analyze . --highlight-diverging-from main

Issue Tracker Integration

Flag mismatches between your code and your tickets:

uv run git-graphable analyze . --highlight-issue-inconsistencies --issue-pattern "[A-Z]+-[0-9]+" --issue-engine jira --jira-url "https://your-org.atlassian.net"

Customizable Scoring & Styling

Adjust hygiene penalties and visual styles to match your team's workflow:

# Aggressive penalty for direct pushes and custom teal color for critical branches
uv run git-graphable analyze . --check --penalty direct_push_penalty:50 --style critical:stroke:teal

Interactive HTML Viewer

Generate a self-contained HTML file with a searchable graph, details sidebar, and an interactive legend to live-toggle all highlight modes:

uv run git-graphable analyze . --engine html -o graph.html

Configuration

Git Graphable can be configured via a TOML file (.git-graphable.toml or pyproject.toml). CLI flags always take precedence over configuration file settings.

Example .git-graphable.toml

[git-graphable]
production_branch = "main"
development_branch = "develop"
simplify = true
limit = 100
date_format = "%Y-%m-%d"
highlight_critical = true
critical_branches = ["main", "prod"]
highlight_pr_status = true
highlight_wip = true
wip_keywords = ["wip", "todo", "fixme", "temp"]
highlight_direct_pushes = true
highlight_squashed = true
highlight_back_merges = true
highlight_silos = true
silo_commit_threshold = 20
silo_author_count = 1

# Issue Tracker
highlight_issue_inconsistencies = true
highlight_release_inconsistencies = true
highlight_collaboration_gaps = true
highlight_longevity_mismatch = true
issue_pattern = "JIRA-[0-9]+"
issue_engine = "jira"
jira_url = "https://your-org.atlassian.net"
jira_closed_statuses = ["Done", "Closed", "Resolved"]
released_statuses = ["Released"]
author_mapping = { "Git Name" = "Jira Name" }
longevity_threshold_days = 14

# Custom Scoring
[git-graphable.hygiene_weights]
direct_push_penalty = 25
direct_push_cap = 75
wip_commit_penalty = 5

# Custom Theme
[git-graphable.theme.critical]
stroke = "teal"
width = 2

[git-graphable.theme.direct_push]
stroke = "magenta"
dash = "dotted"

Development

Run tests and linting:

just check

CI/CD

This project uses GitHub Actions for continuous integration and automated publishing:

  • CI: Runs just check on all pushes and PRs to main.
  • Publish: Automatically builds and publishes to PyPI when a version tag (v*) is pushed.

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

git_graphable-0.6.0.tar.gz (112.3 kB view details)

Uploaded Source

Built Distribution

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

git_graphable-0.6.0-py3-none-any.whl (51.1 kB view details)

Uploaded Python 3

File details

Details for the file git_graphable-0.6.0.tar.gz.

File metadata

  • Download URL: git_graphable-0.6.0.tar.gz
  • Upload date:
  • Size: 112.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for git_graphable-0.6.0.tar.gz
Algorithm Hash digest
SHA256 e8ade623c30c816b08d973507e37535ea2aebeab2ccbf11b0b258714b69f2626
MD5 4e7996df9acac13d1c3f8d732e297fb6
BLAKE2b-256 ab2b034addff129953292d58b2ac47fd659181724d5a765e0a1d77acf377654d

See more details on using hashes here.

File details

Details for the file git_graphable-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: git_graphable-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 51.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for git_graphable-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6950aae582bbc63de92c3be2038099f68793fe4f1f0aa6b0dce3f353520311f
MD5 97066b2d35481c596942ed84e45f07ef
BLAKE2b-256 b4b1b7399b3211c8e1397e98860359a4c6007aea99d1019d7718ca14b1c81b97

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