123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566(*******************************************************************************)(* Volgo - a Versatile OCaml Library for Git Operations *)(* Copyright (C) 2024-2025 Mathieu Barbin <mathieu.barbin@gmail.com> *)(* *)(* This file is part of Volgo. *)(* *)(* Volgo is free software; you can redistribute it and/or modify it under *)(* the terms of the GNU Lesser General Public License as published by the *)(* Free Software Foundation either version 3 of the License, or any later *)(* version, with the LGPL-3.0 Linking Exception. *)(* *)(* Volgo is distributed in the hope that it will be useful, but WITHOUT ANY *)(* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *)(* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License and *)(* the file `NOTICE.md` at the root of this repository for more details. *)(* *)(* You should have received a copy of the GNU Lesser General Public License *)(* and the LGPL-3.0 Linking Exception along with this library. If not, see *)(* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)(*******************************************************************************)open!Importletparse_log_line_exn~line:str:Vcs.Log.Line.t=matchVcs.Private.try_with(fun()->matchString.split(String.stripstr)~on:' 'with|[]->assertfalse(* [String.split] never returns the empty list. *)|[rev]->Vcs.Log.Line.Root{rev=Vcs.Rev.vrev}|[rev;parent]->Commit{rev=Vcs.Rev.vrev;parent=Vcs.Rev.vparent}|[rev;parent1;parent2]->Merge{rev=Vcs.Rev.vrev;parent1=Vcs.Rev.vparent1;parent2=Vcs.Rev.vparent2}|_::_::_::_->raise(Err.E(Err.create[Pp.text"Too many words (expected 1, 2, or 3)."])))with|Okt->t|Errorerr->raise(Err.E(Err.add_contexterr[Err.sexp[%sexp"Volgo_git_backend.Log.parse_log_line_exn",{line=(str:string)}]]));;moduleMake(Runtime:Runtime.S)=structtypet=Runtime.tletget_log_linest~repo_root=Runtime.gitt~cwd:(repo_root|>Vcs.Repo_root.to_absolute_path)~args:["log";"--all";"--pretty=format:%H %P"]~f:(funoutput->letopenResult.Monad_syntaxinlet*output=Vcs.Git.Result.exit0_and_stdoutoutputinVcs.Private.try_with(fun()->List.map(String.split_linesoutput)~f:(funline->parse_log_line_exn~line)));;end