Skip to main content

A CLI tool to detect which tests are impacted by a git commit.

Project description

Git Commit Tracker

Git Commit Tracker is a small CLI utility to determine which tests a given Git commit touches by mapping changed file ranges to test definitions discovered via Tree-sitter ASTs.

Key principles

  • AST-first: parse files to locate test definitions and compute exact line ranges.
  • Language-driven: pick a parser by file extension and cache parsers for reuse.
  • Conservative impact: report tests that overlap changed line ranges (added, removed, or modified).

Quick start

Prerequisites

  • Python 3.8+
  • Git

Install for development

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Install from PyPI

pip install git-commit-tracker

Run the CLI

impact-analyzer --commit <SHA> --repo <PATH_OR_URL>

Common examples

  • Analyze a remote repo (auto-clones): impact-analyzer --commit 75cdcc5 --repo https://github.com/example/repo
  • Analyze a local repo: impact-analyzer --commit 45433fd --repo ./my-local-project
  • Analyze a private repo: impact-analyzer --commit 45433fd --repo https://<your-access-token>@github.com/owner/repo.git

What it detects

  • JavaScript / TypeScript: test, it, describe call expressions (including .only, .skip).
  • Python: functions named test_*.
  • Other languages: extend by adding parsers and detection rules.

Project structure

  • src/impact_analyzer/cli.py: CLI entrypoint and repo handling (cloning, temp dirs).
  • src/impact_analyzer/engine.py: Main orchestration—diff inspection, parsing, and result formatting.
  • src/impact_analyzer/parser.py: Tree-sitter parsing and AST traversal to find tests and ranges.
  • src/impact_analyzer/languages.py: Extension-to-parser mapping and parser caching.
  • src/impact_analyzer/git_utils.py: Helpers to extract changed line ranges from commit diffs.

Architecture notes

  • The CLI resolves the repo (local path or remote URL) and checks out the requested commit.
  • git_utils extracts hunks and changed line sets between the commit and its parent.
  • Parsers in languages.py are looked up by extension; parser.py walks the AST and emits test identifiers and their line ranges.
  • engine.py computes intersections between changed lines and test ranges to produce the final impact report.

Extending the tool

  1. Add a Tree-sitter grammar dependency (if needed) and expose it via languages.py.
  2. Add detection logic for new test forms in parser.py.

License

MIT

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_commit_tracker-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

git_commit_tracker-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file git_commit_tracker-0.1.0.tar.gz.

File metadata

  • Download URL: git_commit_tracker-0.1.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for git_commit_tracker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0d44657edde988a5840f2d9f02ef74e5eb926696225b93aee43690ac35b764f3
MD5 1c5ac3077502d7a41cc22fc93a518fc4
BLAKE2b-256 2cb220b272e01ee67e106d0daf2e6c20496de95fab1a6d3853942480de81b160

See more details on using hashes here.

File details

Details for the file git_commit_tracker-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for git_commit_tracker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b7c8bb4ac80205db1d56602790201550b784d5583ca97487ade63eac345ef71
MD5 83d98093321aefbe8aebeb8dd8e4fb64
BLAKE2b-256 d6eb7558b57d9b9922d7783687cca0cce633e43e14a9f64e4a34e7a895d6429a

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