ref:main

feat: merge-base and ancestry helpers #43

open Opened by cole.christensen@gmail.com

Links

No links yet.

graph/ has walker primitives but no explicit merge-base API. Needed for PR "N ahead / M behind" UIs, three-way merge base selection, and rebase.

Scope

  • Graph.merge_base(repo, a, b) :: {:ok, sha} | {:error, :disjoint}
  • Graph.merge_bases/3 — multiple best-common-ancestors (for octopus / recursive merge)
  • Graph.is_ancestor?(repo, a, b)a reachable from b?
  • Graph.ahead_behind(repo, a, b) :: %{ahead: n, behind: m}

Acceptance

  • Matches git merge-base / git merge-base --all on a fixture with linear history, diamonds, and cross-merges.
  • ahead_behind matches git rev-list --count --left-right.

Blocks: server-side merge primitives (separate ticket), PR UI.