← Back to Pull requests

feat: fast-forward, push and clean up branches #502

Closed
unknown closed this pull request without merging on Nov 10, 2026 18:15 UTC
View on GitHub
unknown unknown commented on Nov 10, 2026 17:14 UTC
Author

Summary

Implements add-branch-sync-actions, the last change planned in #495. Stacked on #501 (base feat/repository-maintenance); the first commit archives add-repository-maintenance so this change validates against the archived specs.

  • Fast-forward (fastforward.go): exact rev-list --left-right --count in the preview; only when behind and not ahead, never touching the network. Checked-out branches: merge --ff-only --no-autostash --end-of-options <to> in their worktree with WithoutCancel + 3 min (tracked changes / in-progress operation block; sessions must be acknowledged; overwritten untracked files reuse switch's overwrittenPaths). Unchecked branches: merge-base --is-ancestor then update-ref with the old value.

  • Push / publish (push.go): pushes the previewed OID (push --porcelain --end-of-options <remote> <OID>:refs/heads/<target>) through remoteGit after re-checking under the gate and releasing it; publish picks --remote, remote.pushDefault, origin or the only remote, validates the target name, and writes branch.<b>.remote/merge only after success. ! status lines → rejected ("先获取远程再快进"); no status line + existing pre-push hook (honours core.hooksPath) → "被 pre-push 钩子拒绝". Forbidden argv (--force, --delete, --mirror, --all, --tags, --follow-tags, --no-verify, + refspecs) asserted by a git wrapper.

  • Delete / cleanup (branchdelete.go): Branch.mergedIntoDefault from one for-each-ref --merged; preview groups branches into 已包含 / 有独有提交 via rev-list --count <OID> --not --exclude=<b> --branches --remotes --tags --glob=refs/webmux/ <other HEADs> (commits shared only by other selected branches count as unique, so twin branches cannot both be deleted); delete uses update-ref -d <ref> <OID> + config --remove-section and returns git branch <b> <OID> recovery commands. Unmerged branches need acknowledgeUnmerged.

  • API / CLI: six routes …/branches/{fast-forward,push,delete}-preview + execute with isolated confirmation purposes; webmux repo ff, repo push [--remote] [--to], repo branch-rm (BRANCH… | --cleanup) [--unmerged].

  • Web: pure branchActions() decides 快进到上游 / 推送… / 发布分支… / 删除分支… everywhere (worktree menus on home, sidebar and panel; worktree details; branch rows). FastForwardBranch, PushBranch, DeleteBranches flows open as RepositoryPanel subviews or in one shared BranchOperationDialog shell from home/sidebar (one shell for the three flows instead of three near-identical ones). 清理分支(N) on the 本地分支 header preselects only 已包含.
  • Verification

  • make format, make check pass; make test-go green; 500-branch Branches incl. mergedIntoDefault ~95 ms.

  • Vitest: only base64url.test.ts fails locally (Node 24); TerminalGraphics/TerminalSyncOutput failed once under full-suite load and pass 24/24 alone.

  • Playwright: branch-operations.spec.ts (fetch in the panel then fast-forward; publish and ahead count back to zero; cleanup with the squash-merged branch unselected), repository-maintenance, worktree-switch, worktrees — 36 passed.
  • User stories

    New US-J18 (fast-forward, push and clean up branches); updated US-J14, coverage, usage/protocol docs, verification log.

    Screenshots

    Demo repo as in #498, plus main one commit behind origin/main and a squash-merged leftover feat/sq (unique commit, upstream gone).

    Worktree menu: 快进到上游 when only behind

    | Viewport / theme | Before (#501) | After |
    |---|---|---|
    | desktop 1280×900 light | !before | !after |
    | desktop 1280×900 dark | !before | !after |
    | tablet 768×800 light | !before | !after |
    | tablet 768×800 dark | !before | !after |
    | phone 390×844 light | !before | !after |
    | phone 390×844 dark | !before | !after |

    分支 tab: row actions, 已合入默认分支 badge, 清理分支(N)

    | Viewport / theme | Before (#501) | After |
    |---|---|---|
    | desktop 1280×900 light | !before | !after |
    | desktop 1280×900 dark | !before | !after |
    | tablet 768×800 light | !before | !after |
    | tablet 768×800 dark | !before | !after |
    | phone 390×844 light | !before | !after |
    | phone 390×844 dark | !before | !after |

    清理分支 preview as a panel subview (new)

    | Viewport | Light | Dark |
    |---|---|---|
    | desktop 1280×900 | !light | !dark |
    | tablet 768×800 | !light | !dark |
    | phone 390×844 | !light | !dark |

    Interaction

  • Desktop 1280×900 light — 工作树 tab row menu on docs/refresh → 发布分支… → preview (remote, target, redacted push URL) → 发布 → 完成:
  • !publish flow

  • Phone 390×844 light — 分支 tab → 清理分支(2) → chore/old-deps preselected, feat/sq (unique commits) not → delete → results with recovery command → 完成:
  • !cleanup flow

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mzdluo123 Review duration: 60m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #502"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%