123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119(********************************************************************************)(* crs - A tool for managing code review comments embedded in source code *)(* Copyright (C) 2024-2025 Mathieu Barbin <mathieu.barbin@gmail.com> *)(* *)(* This file is part of crs. *)(* *)(* crs 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. *)(* *)(* crs 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. *)(********************************************************************************)letfind_enclosing_repo~from=letvcs_git=Volgo_git_unix.create()inmatchVcs.find_enclosing_repo_rootvcs_git~from~store:[Fsegment.dot_git,`Git;Fsegment.dot_hg,`Hg]with|Some((`Gitasvcs_kind),repo_root)->{Enclosing_repo.vcs_kind;repo_root;vcs=(vcs_git:>Enclosing_repo.vcs)}|Some((`Hgasvcs_kind),repo_root)->letvcs_hg=Volgo_hg_unix.create()in{Enclosing_repo.vcs_kind;repo_root;vcs=(vcs_hg:>Enclosing_repo.vcs)}|None->Err.raisePp.O.[Pp.text"Failed to locate enclosing repo root from '"++Pp_tty.path(moduleAbsolute_path)from++Pp.text"'."][@coverageoff];;letrelativize~repo_root~cwd~path=letpath=Absolute_path.relativize~root:cwdpathinmatchAbsolute_path.chop_prefixpath~prefix:(repo_root|>Vcs.Repo_root.to_absolute_path)with|Somerelative_path->Vcs.Path_in_repo.of_relative_pathrelative_path|None->Err.raisePp.O.[Pp.text"Path "++Pp_tty.path(moduleAbsolute_path)path++Pp.text" is not in repo."];;letfilters=letopenCommand.Stdinletonefilter=letfilter_str=Cr_comment.Filter.to_stringfilterinlet+select=Arg.flag[filter_str;Printf.sprintf"%c"(Cr_comment.Filter.shorthandfilter)]~doc:(matchfilterwith|All->"Select all CRs types (this is the default)."|Invalid->"Select only invalid CRs."|CRs->"Select only CRs of type CR."|XCRs->"Select only CRs of type XCR."|Now|Soon|Someday->Printf.sprintf"Select only CRs to be worked on %s."filter_str)inifselectthen[filter]else[]inlet+all=oneAlland+invalid=oneInvalidand+crs=oneCRsand+xcrs=oneXCRsand+now=oneNowand+soon=oneSoonand+someday=oneSomedayinletfilters=List.concat[all;invalid;crs;xcrs;now;soon;someday]inmatchfilterswith|[]->`All|_::_asfilters->`Onlyfilters;;letwith_user_mentions_arg=letopenCommand.StdinArg.named_with_default["with-user-mentions"]Param.bool~default:false~doc:"If true, prefix the assignee's login with '@' in annotation messages (e.g., \
$(i,@assignee-login)), which may trigger a notification in some environments \
(such as GitHub PR reviews). If false, the assignee's login is shown without the \
'@', so no notification is triggered. Note: For a notification to be triggered, \
the user must also be included in the configured user-mentions allowlist. This \
flag only affects notification behavior, as the assignee's name is always \
displayed.";;letemit_github_annotations_arg~default=letopenCommand.StdinArg.named_with_default["emit-github-annotations";"with-github-annotations-warnings"]Param.bool~default~doc:"Optionally emit GitHub Annotations on $(b,stderr) to highlight issues (such as \
deprecated constructs, errors, etc.) in addition to regular errors and warnings.\n\n\
This may be convenient when running jobs from within GitHub Actions to increase \
the chance of detecting these issues when inspecting the jobs summary pages.\n\n\
The $(i,--with-github-annotations-warnings) alias is deprecated and will be \
removed in a future release. Please update.";;