fangorn/ex_git_objectstore
public
ref:main
feat: server-side merge primitives for PR merge button (merge-commit, squash, rebase, ff-only) #40
open
Opened by cole.christensen@gmail.com
Links
No links yet.
Merge.merge_commits/4 returns a merged tree but does not advance a ref or write a merge commit. Hosting products need four merge modes driven server-side:
- Merge commit: create a new commit with two parents, advance the target ref.
- Squash: collapse the source branch into one commit on the target.
- Rebase: replay the source commits on top of the target, advance.
- Fast-forward-only: refuse if not FF, otherwise just move the ref.
Scope
Merge.merge/5(repo, target_ref, source_sha, mode, author_committer_opts)— returns{:ok, new_ref_sha}or conflict detail.- Uses existing
Authorization/hook surface viaReceivePack-style pre/post hooks so the hosting layer can veto. - Conflict reporting: return
{:error, {:conflicts, [%{path, base, ours, theirs}]}}so callers can render a UI.
Acceptance
- Each of the four modes produces a commit identical to what
git merge --no-ff/--squash/git rebase/git merge --ff-onlyproduces client-side (tree equality, not SHA equality because author/committer timestamps differ). - Round-trip with real git: after server-side merge,
git fetchfrom a client shows the new ref with the expected shape.