123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172(*******************************************************************************)(* 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. *)(*******************************************************************************)moduleT=structtypet={insertions:int;deletions:int}letto_dyn{insertions;deletions}=Dyn.Record["insertions",Dyn.Intinsertions;"deletions",Dyn.Intdeletions];;letsexp_of_tt=Dyn.to_sexp(to_dynt)letcomparet({insertions;deletions}ast2)=ifphys_equaltt2then0else(matchInt.comparet.insertionsinsertionswith|0->Int.comparet.deletionsdeletions|n->n);;letequalab=compareab=0letzero={insertions=0;deletions=0}let(+)t1t2={insertions=t1.insertions+t2.insertions;deletions=t1.deletions+t2.deletions};;endincludeTletsumts=List.foldts~init:T.zero~f:T.(+)letto_string_hum{insertions;deletions}=letint_humi=Int.to_string_humiinmatch[(ifinsertions>0thenSome("+"^int_huminsertions)elseNone);(ifdeletions>0thenSome("-"^int_humdeletions)elseNone)]|>List.filter_optwith|[]->"0"|[hd]->hd|[a;b]->a^", "^b|_::_::_::_->assertfalse;;lettotal{insertions;deletions}=Int.addinsertionsdeletionsletis_zero{insertions;deletions}=insertions=0&&deletions=0