This repository was archived by the owner on Sep 26, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +29
-15
lines changed
Expand file tree Collapse file tree 2 files changed +29
-15
lines changed Original file line number Diff line number Diff line change 11use anyhow:: Result ;
22
33use crate :: app;
4+ use crate :: git:: git_ls_files;
45
56/// Check that markdown is styled properly
67#[ derive( clap:: Args , Debug ) ]
@@ -9,20 +10,22 @@ pub struct Cli {}
910
1011impl Cli {
1112 pub fn exec ( self ) -> Result < ( ) > {
12- app:: exec (
13- "markdownlint" ,
14- [
15- "--config" ,
16- "scripts/.markdownlintrc" ,
17- "--ignore" ,
18- "scripts/node_modules" ,
19- "--ignore" ,
20- "website/node_modules" ,
21- "--ignore" ,
22- "target" ,
23- "." ,
24- ] ,
25- true ,
26- )
13+ let files = git_ls_files ( Some ( "*.md" ) ) ?;
14+ if files. is_empty ( ) {
15+ return Ok ( ( ) ) ;
16+ }
17+
18+ let args: Vec < & str > = vec ! [
19+ "--config" ,
20+ "scripts/.markdownlintrc" ,
21+ // We should fix these as well. Previously these files were not linted.
22+ "--ignore" ,
23+ ".github"
24+ ]
25+ . into_iter ( )
26+ . chain ( files. iter ( ) . map ( String :: as_str) )
27+ . collect ( ) ;
28+
29+ app:: exec ( "markdownlint" , & args, true )
2730 }
2831}
Original file line number Diff line number Diff line change @@ -165,3 +165,14 @@ pub fn run_and_check_output(args: &[&str]) -> Result<String> {
165165fn is_warning_line ( line : & str ) -> bool {
166166 line. starts_with ( "warning: " ) || line. contains ( "original line endings" )
167167}
168+
169+ /// Returns a list of tracked files. If `pattern` is specified, it filters using that pattern.
170+ pub fn git_ls_files ( pattern : Option < & str > ) -> Result < Vec < String > > {
171+ let args = match pattern {
172+ Some ( p) => vec ! [ "ls-files" , p] ,
173+ None => vec ! [ "ls-files" ] ,
174+ } ;
175+
176+ let output = run_and_check_output ( & args) ?;
177+ Ok ( output. lines ( ) . map ( str:: to_owned) . collect ( ) )
178+ }
You can’t perform that action at this time.
0 commit comments