Skip to content

feat: Add branch diff and reject endpoints#9

Merged
DarlingtonDeveloper merged 2 commits into
mainfrom
feat/branch-review-endpoints
Feb 17, 2026
Merged

feat: Add branch diff and reject endpoints#9
DarlingtonDeveloper merged 2 commits into
mainfrom
feat/branch-review-endpoints

Conversation

@DarlingtonDeveloper
Copy link
Copy Markdown
Collaborator

Summary

Implements the branch diff and reject endpoints as specified in the briefing.

New Endpoints

1. Branch Diff Endpoint

  • GET /api/v1/prompts/{slug}/branches/{branch_name}/diff
  • Compares branch head version content vs main branch latest version content
  • Returns JSON with branch_name, target_section, current_content, proposed_content, diff_summary
  • Returns 404 if branch does not exist

2. Branch Reject Endpoint

  • POST /api/v1/prompts/{slug}/branches/{branch_name}/reject
  • Body: reason string (optional)
  • Updates branch status to rejected
  • Returns the updated branch

Implementation Details

  • Uses existing vcs.history() method to get branch head and main head versions
  • Added comprehensive diff summary generation with section and variable comparison
  • Follows existing code patterns and error handling conventions
  • Added Pydantic models for request/response validation

Testing

  • All existing tests pass (294/294)
  • Added 4 new comprehensive tests covering both endpoints
  • Tests include success cases and error handling (404s)

Changes Made

  • Modified prompt_forge/api/branches.py to add new endpoints
  • Added helper functions for diff generation
  • Added comprehensive test coverage
  • No breaking changes to existing functionality

Resolves requirements from briefing feat/branch-review-endpoints

- Add GET /api/v1/prompts/{slug}/branches/{branch_name}/diff endpoint
  - Compares branch head content vs main branch latest content
  - Returns branch_name, target_section, current/proposed content, and diff_summary
  - Handles missing branches with 404 responses

- Add POST /api/v1/prompts/{slug}/branches/{branch_name}/reject endpoint
  - Updates branch status to 'rejected' with optional reason
  - Returns the updated branch object
  - Handles missing branches with 404 responses

- Add helper function _generate_diff_summary() for readable change descriptions
- Add comprehensive tests for both new endpoints
- Add new Pydantic models: BranchReject, BranchDiffResponse

All existing tests pass and new functionality is fully tested.
@DarlingtonDeveloper DarlingtonDeveloper merged commit 06ba754 into main Feb 17, 2026
2 checks passed
@DarlingtonDeveloper DarlingtonDeveloper deleted the feat/branch-review-endpoints branch February 17, 2026 01:26
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.

1 participant