Something went wrong. Try again.
Correctness- and interoperability-oriented Tangled CLI
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960open Camlet_domain
let ( let* ) = Result.bind
let identity_of_remote (remote : Context_ports.remote) = let urls = [ remote.fetch_url; remote.push_url ] in match List.find_map Forge_url.tangled urls with | Some identity -> Some (Repository_context.Tangled identity) | None -> List.find_map Forge_url.radicle urls |> Option.map (fun rid -> Repository_context.Radicle rid)
let surface_of_remote (remote : Context_ports.remote) = match identity_of_remote remote with | None -> None | Some identity -> let tracking_ref, revision, surface_relation = match (remote.tracking_ref, remote.comparison) with | None, _ -> (None, None, Repository_context.missing) | Some tracking_ref, None -> (Some tracking_ref, None, Repository_context.missing) | Some tracking_ref, Some comparison -> ( Some tracking_ref , Some comparison.commit , Repository_context.relation ~ahead:comparison.ahead ~behind:comparison.behind ) in Some Repository_context. { remote = remote.name ; identity ; tracking_ref ; revision ; relation = surface_relation }
let run ~ports ~repo = let* git_snapshot = ports.Context_ports.inspect_git repo in let* jj_snapshot = ports.inspect_jj git_snapshot.root in let git = Repository_context. { root = git_snapshot.root ; head = git_snapshot.head ; branch = git_snapshot.branch ; dirty = git_snapshot.dirty } in let jj = Option.map (fun snapshot -> Repository_context. { commit = snapshot.Context_ports.commit ; change_id = snapshot.change_id ; bookmarks = snapshot.bookmarks }) jj_snapshot in let surfaces = List.filter_map surface_of_remote git_snapshot.remotes in Ok Repository_context.{ git; jj; surfaces; agreement = agreement surfaces }