11// Copyright 2026 the Prep Authors
22// SPDX-License-Identifier: Apache-2.0 OR MIT
33
4- use std:: process:: Command ;
5-
64use anyhow:: { Context , bail, ensure} ;
75use time:: UtcDateTime ;
86
97use crate :: session:: Session ;
8+ use crate :: tools:: cargo:: CargoDeps ;
9+ use crate :: tools:: ripgrep:: { Ripgrep , RipgrepDeps } ;
1010use crate :: ui;
1111use crate :: ui:: style:: { ERROR , HEADER , LITERAL , NOTE } ;
1212
@@ -16,13 +16,26 @@ use crate::ui::style::{ERROR, HEADER, LITERAL, NOTE};
1616/// Verify copyright headers.
1717///
1818/// In `strict` mode ripgrep version is locked.
19- pub fn run ( session : & mut Session , _strict : bool ) -> anyhow:: Result < ( ) > {
20- let config = session. config ( ) ;
21- let project = config. project ( ) ;
19+ pub fn run ( session : & mut Session , strict : bool ) -> anyhow:: Result < ( ) > {
20+ let mut cmd = if strict {
21+ let tools_cfg = session. config ( ) . tools ( ) ;
22+ let cargo_ver_req = tools_cfg. rust ( ) . clone ( ) ;
23+ let rustup_ver_req = tools_cfg. rustup ( ) . clone ( ) ;
24+ let ver_req = tools_cfg. ripgrep ( ) . clone ( ) ;
25+ let toolset = session. toolset ( ) ;
26+ let cargo_deps = CargoDeps :: new ( rustup_ver_req) ;
27+ let deps = RipgrepDeps :: new ( cargo_deps, cargo_ver_req) ;
28+ toolset. get :: < Ripgrep > ( & deps, & ver_req) ?
29+ } else {
30+ let toolset = session. toolset ( ) ;
31+ let cargo_deps = CargoDeps :: new ( None ) ;
32+ let deps = RipgrepDeps :: new ( cargo_deps, None ) ;
33+ toolset. get :: < Ripgrep > ( & deps, None ) ?
34+ } ;
35+
36+ let project = session. config ( ) . project ( ) ;
2237 let header_regex = header_regex ( project. name ( ) , project. license ( ) ) ;
2338
24- // TODO: Strict mode for ripgrep.
25- let mut cmd = Command :: new ( "rg" ) ;
2639 let cmd = cmd
2740 . current_dir ( session. root_dir ( ) )
2841 . arg ( header_regex)
0 commit comments