Skip to content

uf.rebase-pr: port global resolve-branch-conflict command (rebase conflicted PR head onto base) #851

Closed

Description

@jflowers

Summary

Port the verified personal global command
~/.config/opencode/commands/resolve-branch-conflict.md into the
UF command set as .opencode/commands/uf.rebase-pr.md, invoked
as /uf.rebase-pr <PR_NUMBER>: rebases a conflicted PR's head
branch onto its base branch, resolves conflicts, and
force-pushes with lease so the PR can be merged with a rebase
once approved.

Why

  • The capability lives only in a personal global command;
    scaffolded UF repos do not receive it.
  • /uf.finale only syncs the current feature branch pre-PR
    (its step 4). Nothing addresses an already-open PR reporting
    conflicts.
  • The source command is verified in daily use: takes a PR
    number, rebases head onto base, handles fork remotes.

Command behavior (from the verified source)

  1. Arguments: PR number required, validated ^[1-9][0-9]*$
    before any tool call; invalid → STOP.
  2. Prerequisites: which gh, gh auth status; repo detected
    via gh repo view — never hardcoded.
  3. Fetch PR: gh pr view <N> --json number,title,state, headRefName,baseRefName,mergeable,mergeStateStatus, baseRepository,headRepository; STOP if CLOSED/MERGED or
    already conflict-free (MERGEABLE + CLEAN). Record
    HEAD_BRANCH, BASE_BRANCH, BASE_REPO, HEAD_REPO.
  4. Checkout: gh pr checkout <N>, with fallback to fetching
    the head ref directly from HEAD_REPO.
  5. Remotes: resolve BASE_REMOTE/HEAD_REMOTE by matching
    git remote -v URLs against the PR's base/head repos — never
    assume origin is the base repo.
  6. Rebase: git fetch <BASE_REMOTE> then
    git rebase <BASE_REMOTE>/<BASE_BRANCH>.
  7. Conflicts: resolve flagged files only, preserving the PR
    author's intent; no guessing — STOP and offer
    git rebase --abort on ambiguity.
  8. Push: git push --force-with-lease <HEAD_REMOTE> <HEAD_BRANCH> only; MUST NOT push to base or protected
    branches.
  9. Verify: re-check mergeable/mergeStateStatus; report.
    MUST NOT merge, approve, or close the PR.

Scope

  • .opencode/commands/uf.rebase-pr.md — full port following
    uf.review-pr.md conventions (frontmatter, <protect>,
    session-resume guard)
  • Prefer existing git plugin tools (git_fetch, git_rebase,
    git_rebase_abort, git_push_force_with_lease) over raw
    bash where available (determinism pack DE-001)
  • Scaffold mirror
    internal/scaffold/assets/opencode/commands/uf.rebase-pr.md
    (tool-owned asset; drift tests must stay green)
  • AGENTS.md PR Review Commands table: /uf.rebase-pr [N] —
    Post-PR — rebase conflicted PR head onto base
  • docs/usage.md command reference entry
  • make check green

Notes

  • Distinct from /uf.finale step 4: finale syncs the current
    branch before creating its own PR; this command operates on
    any open PR by number, fork-aware.
  • Source of truth for the port: the global command file
    (personal config, not in any repo).

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions