Skip to content

Add Python AST-based git commit summarizer#1

Draft
Copilot wants to merge 3 commits intodevelopfrom
copilot/add-python-parser-for-changes
Draft

Add Python AST-based git commit summarizer#1
Copilot wants to merge 3 commits intodevelopfrom
copilot/add-python-parser-for-changes

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 12, 2026

No existing tooling parsed Python source structure when summarizing commits — the prior workflow relied on OpenAI GPT. This adds a pure-Python, no-API-key alternative that uses ast to extract structural symbol changes per commit, grouped by day.

Core script: scripts/git_commit_summary.py

  • Fetches before/after file content from git for each changed .py file and parses both with ast
  • Extracts top-level and class-level functions/classes; reports added / modified / deleted / moved
  • Filters noise: docstrings stripped before AST comparison, import-only files skipped, stub bodies (pass/...) not reported as "added"
  • Move detection: symbol deleted from one file + added to another in same commit → reported as moved (old.py → new.py)
  • Outputs plain text or JSON; usable as a CLI tool or imported as a library
# Text summary for a date range
python scripts/git_commit_summary.py --since 2025-01-01 --until 2025-03-01 --branch main

# JSON output (e.g. for downstream tooling)
python scripts/git_commit_summary.py --since 2025-01-01 --output json

Sample output:

============================================================
  2025-06-15  (3 commit(s))
============================================================
  [abc12345] Refactor decoder pipeline  <dev@example.com>
      added    class    'BayesianDecoder'  (src/decoder.py)
      modified function 'ZhangReconstructionImplementation.time_bin_spike_counts_N_i'  (src/reconstruction.py)
      moved    function 'helper'  (utils.py -> core/helpers.py)

GitHub Actions workflow: .github/workflows/python-ast-commit-summarizer.yml

  • workflow_dispatch with start_date, end_date, branch, output_format, show_empty inputs
  • Checks out full history, runs the script, uploads result as a downloadable artifact
  • permissions: contents: read (least-privilege)

Tests: tests/test_git_commit_summary.py

32 unit tests covering symbol extraction, AST normalization, trivial-body detection, import-only file detection, per-file change detection, move resolution, and text/JSON formatting.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 12, 2026 15:43
Co-authored-by: CommanderPho <962210+CommanderPho@users.noreply.github.com>
Co-authored-by: CommanderPho <962210+CommanderPho@users.noreply.github.com>
Copilot AI changed the title [WIP] Add general purpose git commit summarizing workflow Add Python AST-based git commit summarizer Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants