• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mbarbin / crs / 15

13 Apr 2025 07:35PM UTC coverage: 69.78% (+3.1%) from 66.667%
15

push

github

web-flow
Merge pull request #6 from mbarbin/crs-grep

Add a crs command `grep`

14 of 28 new or added lines in 3 files covered. (50.0%)

254 of 364 relevant lines covered (69.78%)

5.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.62
/lib/crs_cli/src/cmd__grep.ml
1
(********************************************************************************)
2
(*  crs - A tool to manipulate code review comments embedded in source code     *)
3
(*  Copyright (C) 2024-2025 Mathieu Barbin <mathieu.barbin@gmail.com>           *)
4
(*                                                                              *)
5
(*  This file is part of crs.                                                   *)
6
(*                                                                              *)
7
(*  crs is free software; you can redistribute it and/or modify it under the    *)
8
(*  terms of the GNU Lesser General Public License as published by the Free     *)
9
(*  Software Foundation either version 3 of the License, or any later version,  *)
10
(*  with the LGPL-3.0 Linking Exception.                                        *)
11
(*                                                                              *)
12
(*  crs is distributed in the hope that it will be useful, but WITHOUT ANY      *)
13
(*  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS   *)
14
(*  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License and     *)
15
(*  the file `NOTICE.md` at the root of this repository for more details.       *)
16
(*                                                                              *)
17
(*  You should have received a copy of the GNU Lesser General Public License    *)
18
(*  and the LGPL-3.0 Linking Exception along with this library. If not, see     *)
19
(*  <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively.        *)
20
(********************************************************************************)
21

22
let main =
23
  Command.make
3✔
24
    ~summary:"Grep for CRs in the tree"
25
    (let%map_open.Command below =
26
       Arg.named_opt
3✔
27
         [ "below" ]
28
         (Param.validated_string (module Fpath))
3✔
29
         ~docv:"PATH"
30
         ~doc:"Only grep below the supplied path."
31
     and sexp = Arg.flag [ "sexp" ] ~doc:"Print the CRs as sexps on stdout." in
3✔
32
     let vcs = Vcs_git_blocking.create () in
2✔
33
     let cwd = Unix.getcwd () |> Absolute_path.v in
2✔
34
     let repo_root = Common_helpers.find_enclosing_repo_root vcs ~from:cwd in
2✔
35
     let below =
2✔
36
       match below with
37
       | None -> Vcs.Path_in_repo.root
2✔
NEW
38
       | Some path -> Common_helpers.relativize ~repo_root ~cwd ~path
×
39
     in
40
     let crs = Crs_parser.grep ~vcs ~repo_root ~below in
41
     if sexp
42
     then
43
       List.iter crs ~f:(fun cr ->
2✔
44
         print_endline (Sexp.to_string_hum [%sexp (cr : Cr_comment.t)]))
1✔
NEW
45
     else print_endline "Table not implemented")
×
46
;;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc