fix: parse multi-hunk diffs in Gitea provider#2137
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
|
Hey @nnhattruong30, |
Add unit tests for GiteaProvider.__add_file_diff covering single-hunk, multi-hunk, and multi-file/multi-hunk diffs, plus empty-diff and API-error handling. The multi-hunk cases are regression tests for The-PR-Agent#2137: they fail against the previous implementation (which reset current_patch on every @@ line, dropping all but the last hunk) and pass with the fix.
User description
Gitea Problem: pr-agent only scanned from the last @@ hunk to the end of the file, missing earlier hunks in multi-hunk diffs.
PR Type
Bug fix
Description
Fix multi-hunk diff parsing in Gitea provider
Only initialize patch on first @@ hunk marker
Prevents overwriting earlier hunks in diffs
Diagram Walkthrough
flowchart LR A["Parse diff lines"] --> B["Encounter @@ marker"] B --> C{"current_patch empty?"} C -->|Yes| D["Initialize current_patch"] C -->|No| E["Append to current_patch"] D --> F["Collect all hunks"] E --> FFile Walkthrough
gitea_provider.py
Add empty check to hunk initialization logicpr_agent/git_providers/gitea_provider.py
current_patchwhen empty