Skip to content

Commit 3d64ad3

Browse files
committed
feat: add --all-files command
1 parent fdcf936 commit 3d64ad3

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/git.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use anyhow::{ensure, Context, Result};
88
use log::debug;
99
use regex::Regex;
1010

11-
pub fn get_paths_from_cmd(paths_cmd: String) -> Result<Vec<AbsPath>> {
11+
pub fn get_paths_from_cmd(paths_cmd: &str) -> Result<Vec<AbsPath>> {
1212
debug!("Running paths_cmd: {}", paths_cmd);
1313
let output = Command::new("sh")
1414
.arg("-c")

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ pub enum PathsOpt {
126126
/// The user didn't specify any paths, so we'll automatically determine
127127
/// which paths to check.
128128
Auto,
129+
AllFiles,
129130
PathsFile(AbsPath),
130131
PathsCmd(String),
131132
Paths(Vec<String>),
@@ -175,9 +176,10 @@ pub fn do_lint(
175176
};
176177
get_changed_files(&git_root, relative_to.as_deref())?
177178
}
178-
PathsOpt::PathsCmd(paths_cmd) => get_paths_from_cmd(paths_cmd)?,
179+
PathsOpt::PathsCmd(paths_cmd) => get_paths_from_cmd(&paths_cmd)?,
179180
PathsOpt::Paths(paths) => get_paths_from_input(paths)?,
180181
PathsOpt::PathsFile(file) => get_paths_from_file(file)?,
182+
PathsOpt::AllFiles => get_paths_from_cmd("git grep -Il .")?,
181183
};
182184

183185
// Sort and unique the files so we pass a consistent ordering to linters

src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ struct Args {
6969
#[clap(long, arg_enum, default_value_t = RenderOpt::Default, global=true)]
7070
output: RenderOpt,
7171

72-
/// Paths to lint. lintrunner will still respect the inclusions and
7372
#[clap(subcommand)]
7473
cmd: Option<SubCommand>,
7574

75+
/// Paths to lint. lintrunner will still respect the inclusions and
7676
/// exclusions defined in .lintrunner.toml; manually specifying a path will
7777
/// not override them.
7878
#[clap(conflicts_with_all = &["paths-cmd", "paths-from"], global = true)]
@@ -92,6 +92,10 @@ struct Args {
9292
/// If set, output json to the provided path as well as the terminal.
9393
#[clap(long, global = true)]
9494
tee_json: Option<String>,
95+
96+
/// Run lintrunner on all files in the repo. This could take a while!
97+
#[clap(long, conflicts_with_all=&["paths", "paths-cmd", "paths-from", "revision", "merge-base-with"], global = true)]
98+
all_files: bool,
9599
}
96100

97101
#[derive(Debug, Parser)]
@@ -211,6 +215,8 @@ fn do_main() -> Result<i32> {
211215
PathsOpt::PathsCmd(paths_cmd)
212216
} else if !args.paths.is_empty() {
213217
PathsOpt::Paths(args.paths)
218+
} else if args.all_files {
219+
PathsOpt::AllFiles
214220
} else {
215221
PathsOpt::Auto
216222
};

0 commit comments

Comments
 (0)