Implement Pull Request Merge in Sztabina (SZ-86)
rk@tigase.net opened 2 weeks ago

Summary

Pull Request workflow implements all steps except actual merge in backend. The merge is currently stubbed and returns HTTP 501 (Not Implemented).
Sztab backend and UI correctly invoke merge, enforce authorization and approval rules, but Sztabina does not yet perform the actual Git merge.


Current Behavior

  • UI invokes POST /api/pullrequests/{id}/merge
  • Backend:
    • Validates PR status (APPROVED)
    • Validates reviewer approvals
    • Validates authorization (author or ADMIN / PM)
    • Calls Sztabina via GitManipulationClient.mergeByUrl(...)
  • Sztabina responds with 404 / Not Found
  • Backend translates this to 501 Not Implemented
  • UI displays branded error message:
    “Merge is not implemented yet”

This behavior is intentional and correct for now.


Expected Behavior

  • Sztabina performs an actual Git merge:
    • base = target branch
    • head = source branch
  • Merge result returned to backend
  • Backend transitions PR to MERGED
  • UI reflects merged state (badge, checkmark, disabled actions)

Scope of Work

1. Sztabina – Git Merge Implementation

  • Add merge operation to Git service layer
  • Support merge by repository URL + branch refs
  • Execute merge using local Git engine
  • Handle:
    • Fast-forward merge
    • Non-fast-forward merge
    • Merge conflicts
  • Return structured merge result:
    • SUCCESS
    • CONFLICT
    • ERROR

2. Sztabina – API Endpoint

  • Implement merge endpoint (currently stubbed / missing)
  • Accept:
    • repository URL
    • base branch
    • head branch
  • Return:
    • HTTP 200 on success
    • HTTP 409 on conflict
    • HTTP 500 on unexpected failure

3. Backend – Error Translation (Minor)

  • Map merge conflict → HTTP 409
  • Preserve 501 only if merge is truly unsupported
  • No change to authorization / validation logic

4. Tests

  • Sztabina unit tests for merge logic
  • Sztabina API tests
  • Backend integration test verifying:
    • Approved PR → merge success
    • Conflict → PR remains unmerged

Out of Scope

  • UI conflict resolution
  • Rebase / squash strategies
  • Commit message customization
  • Branch protection rules

Worklog (Planned)

TaskEstimated Time
Analyze existing Git engine & repo layout0.5h
Implement Git merge logic in Sztabina2.0h
Handle merge conflict detection1.0h
Implement merge API endpoint0.5h
Add Sztabina unit & API tests1.5h
Backend conflict mapping + test0.5h
Manual end-to-end validation0.5h
Total7.5 hours

Notes

  • Backend and UI are already merge-ready
  • This defect is isolated to Sztabina
  • No schema changes required
  • rk@tigase.net commented 5 days ago
    rksuma@Ramakrishnans-MacBook-Pro sztab % git checkout -b feature/sz-86-implement-pull-request-merge
    Switched to a new branch 'feature/sz-86-implement-pull-request-merge'
    rksuma@Ramakrishnans-MacBook-Pro sztab % 
    
  • rk@tigase.net changed state to 'In Progress' 5 days ago
    Previous Value Current Value
    Open
    In Progress
issue 1 of 1
Type
New Feature
Priority
Blocker
Assignee
Version
none
Sprints
n/a
Customer
n/a
Issue Votes (0)
Watchers (3)
Reference
SZ-86
Please wait...
Page is in error, reload to recover