mirror of
https://github.com/j178/prek.git
synced 2026-04-25 02:11:36 +02:00
Support pass multiple files like prek run --files a b c d (#828)
This commit is contained in:
@@ -402,6 +402,7 @@ pub(crate) struct RunArgs {
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with_all = ["all_files", "from_ref", "to_ref"],
|
||||
num_args = 1..,
|
||||
value_hint = ValueHint::AnyPath)
|
||||
]
|
||||
pub(crate) files: Vec<String>,
|
||||
|
||||
@@ -1315,6 +1315,41 @@ fn run_last_commit() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Test `prek run --files` with multiple files.
|
||||
#[test]
|
||||
fn run_multiple_files() -> Result<()> {
|
||||
let context = TestContext::new();
|
||||
context.init_project();
|
||||
context.write_pre_commit_config(indoc::indoc! {r"
|
||||
repos:
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: multiple-files
|
||||
name: multiple-files
|
||||
language: system
|
||||
entry: echo
|
||||
verbose: true
|
||||
types: [text]
|
||||
"});
|
||||
let cwd = context.work_dir();
|
||||
cwd.child("file1.txt").write_str("Hello, world!")?;
|
||||
cwd.child("file2.txt").write_str("Hello, world!")?;
|
||||
context.git_add(".");
|
||||
// multiple `--files`
|
||||
cmd_snapshot!(context.filters(), context.run().arg("--files").arg("file1.txt").arg("file2.txt"), @r#"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
multiple-files...........................................................Passed
|
||||
- hook id: multiple-files
|
||||
- duration: [TIME]
|
||||
file2.txt file1.txt
|
||||
|
||||
----- stderr -----
|
||||
"#);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Test `prek run --directory` flags.
|
||||
#[test]
|
||||
fn run_directory() -> Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user