feat: add diff analyzer for PR change categorization (#118) #176

Closed
Rockachopa wants to merge 1 commits from burn/118-1776218500 into main
Owner

Closes #118.

Pipeline 6.1 — Diff Analyzer: reads unified diffs and categorizes every change.

What it does:

  • Parses unified diff format (git diff output)
  • Categorizes hunks: added, deleted, modified, context
  • Detects file states: new, deleted, renamed, modified
  • Counts lines per category (added, deleted, context)
  • Produces ChangeSummary with per-file and aggregate stats
  • Serializable to dict for JSON output

Data classes:

  • ChangeCategory enum: ADDED, DELETED, MODIFIED, MOVED, CONTEXT
  • Hunk: header, line ranges, content, category classification
  • FileChange: path, old_path (renames), hunks, line counts
  • ChangeSummary: aggregate stats + per-file breakdown, to_dict() for JSON

API:

from diff_analyzer import DiffAnalyzer
analyzer = DiffAnalyzer()
summary = analyzer.analyze(diff_text)
print(summary.to_dict())

Tests: 10 tests covering additions, deletions, modifications, renames, multiple files, mixed hunks, empty diffs, binary files, context-only hunks.

Verification:

  • python3 tests/test_diff_analyzer.py (10/10 pass)
  • python3 -m pytest tests/test_diff_analyzer.py -v (10/10 pass)
Closes #118. Pipeline 6.1 — Diff Analyzer: reads unified diffs and categorizes every change. **What it does:** - Parses unified diff format (git diff output) - Categorizes hunks: added, deleted, modified, context - Detects file states: new, deleted, renamed, modified - Counts lines per category (added, deleted, context) - Produces ChangeSummary with per-file and aggregate stats - Serializable to dict for JSON output **Data classes:** - `ChangeCategory` enum: ADDED, DELETED, MODIFIED, MOVED, CONTEXT - `Hunk`: header, line ranges, content, category classification - `FileChange`: path, old_path (renames), hunks, line counts - `ChangeSummary`: aggregate stats + per-file breakdown, `to_dict()` for JSON **API:** ```python from diff_analyzer import DiffAnalyzer analyzer = DiffAnalyzer() summary = analyzer.analyze(diff_text) print(summary.to_dict()) ``` **Tests:** 10 tests covering additions, deletions, modifications, renames, multiple files, mixed hunks, empty diffs, binary files, context-only hunks. **Verification:** - `python3 tests/test_diff_analyzer.py` (10/10 pass) - `python3 -m pytest tests/test_diff_analyzer.py -v` (10/10 pass)
Rockachopa added 1 commit 2026-04-15 03:27:05 +00:00
Timmy approved these changes 2026-04-15 04:13:25 +00:00
Timmy left a comment
Owner

Feature implementation reviewed - looks solid.

Scope: 2 file(s) changed (463+ / 0-)

Feature implementation reviewed - looks solid. **Scope**: 2 file(s) changed (463+ / 0-)
Author
Owner

Closing: unmergeable due to conflicts or branch protection. Reopen if needed.

Closing: unmergeable due to conflicts or branch protection. Reopen if needed.
Rockachopa closed this pull request 2026-04-16 01:54:05 +00:00
Author
Owner

Closing: unmergeable due to conflicts or branch protection. Reopen if needed.

Closing: unmergeable due to conflicts or branch protection. Reopen if needed.
Author
Owner

Closing: unmergeable due to conflicts or branch protection. Reopen if needed.

Closing: unmergeable due to conflicts or branch protection. Reopen if needed.
Rockachopa reopened this pull request 2026-04-16 02:04:15 +00:00
Author
Owner

Superseded by merged PR #184. Closing as content is already in main.

Superseded by merged PR #184. Closing as content is already in main.
Rockachopa closed this pull request 2026-04-16 02:13:39 +00:00
Rockachopa reopened this pull request 2026-04-16 02:42:00 +00:00
Rockachopa closed this pull request 2026-04-16 02:52:41 +00:00

Pull request closed

Sign in to join this conversation.