123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104(********************************************************************************)(* 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. *)(********************************************************************************)moduleT=struct[@@@coverageoff]typet=|Pull_requestof{author:Vcs.User_handle.t}|Commit[@@derivingequal,sexp_of]endincludeTmoduleName=structtypet=|Pull_request|Commit[@@derivingenumerate]letto_string=function|Pull_request->"pull-request"|Commit->"commit";;endletarg=letopenCommand.Stdinletpull_request_author_switch="pull-request-author"inletreview_mode_switch="review-mode"inlet+name=Arg.named_with_default[review_mode_switch](Param.enumerated~docv:"MODE"(moduleName))~default:Commit~doc:"Specifies the review context in which this command is executed. Use \
$(b,pull-request) when running in the context of a pull request (requires \
$(b,--pull-request-author)). Use $(b,commit) when running in the context of a \
direct commit or push to a branch (default). This setting affects how CRs are \
assigned and annotated."and+pull_request_author=Arg.named_opt[pull_request_author_switch](Param.validated_string~docv:"AUTHOR"(moduleVcs.User_handle))~doc:(Printf.sprintf"When $(b,--%s) is a pull-request this argument must be supplied to set the \
PR author."review_mode_switch)in(* Both errors are covered but disabled due to an issue with bisect_ppx out
edge creating false negative. *)matchnamewith|Commit->let()=ifOption.is_somepull_request_authorthenErr.raise~exit_code:Err.Exit_code.cli_errorPp.O.[Pp.text"Argument "++Pp_tty.kwd(moduleString)("--"^pull_request_author_switch)++Pp.text" should not be set when review mode is "++Pp_tty.kwd(moduleString)"commit"++Pp.text"."][@coverageoff]inCommit|Pull_request->letauthor=matchpull_request_authorwith|Someauthor->author|None->Err.raise~exit_code:Err.Exit_code.cli_errorPp.O.[Pp.text"Argument "++Pp_tty.kwd(moduleString)("--"^pull_request_author_switch)++Pp.text" should be set when review mode is "++Pp_tty.kwd(moduleString)"pull-request"++Pp.text"."][@coverageoff]inPull_request{author};;