Skip duplicate recipe arguments (#1174)
This commit is contained in:
parent
8baebadd18
commit
db35a58a61
@ -284,6 +284,15 @@ impl<'src> Justfile<'src> {
|
||||
search: &Search,
|
||||
ran: &mut BTreeSet<Vec<String>>,
|
||||
) -> RunResult<'src, ()> {
|
||||
let mut invocation = vec![recipe.name().to_owned()];
|
||||
for argument in arguments {
|
||||
invocation.push((*argument).to_string());
|
||||
}
|
||||
|
||||
if ran.contains(&invocation) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let (outer, positional) = Evaluator::evaluate_parameters(
|
||||
context.config,
|
||||
dotenv,
|
||||
@ -300,20 +309,19 @@ impl<'src> Justfile<'src> {
|
||||
Evaluator::recipe_evaluator(context.config, dotenv, &scope, context.settings, search);
|
||||
|
||||
for Dependency { recipe, arguments } in recipe.dependencies.iter().take(recipe.priors) {
|
||||
let mut invocation = vec![recipe.name().to_owned()];
|
||||
|
||||
for argument in arguments {
|
||||
invocation.push(evaluator.evaluate_expression(argument)?);
|
||||
}
|
||||
|
||||
if !ran.contains(&invocation) {
|
||||
let arguments = invocation
|
||||
let arguments = arguments
|
||||
.iter()
|
||||
.skip(1)
|
||||
.map(String::as_ref)
|
||||
.collect::<Vec<&str>>();
|
||||
self.run_recipe(context, recipe, &arguments, dotenv, search, ran)?;
|
||||
}
|
||||
.map(|argument| evaluator.evaluate_expression(argument))
|
||||
.collect::<RunResult<Vec<String>>>()?;
|
||||
|
||||
self.run_recipe(
|
||||
context,
|
||||
recipe,
|
||||
&arguments.iter().map(String::as_ref).collect::<Vec<&str>>(),
|
||||
dotenv,
|
||||
search,
|
||||
ran,
|
||||
)?;
|
||||
}
|
||||
|
||||
recipe.run(context, dotenv, scope.child(), search, &positional)?;
|
||||
@ -339,11 +347,6 @@ impl<'src> Justfile<'src> {
|
||||
}
|
||||
}
|
||||
|
||||
let mut invocation = vec![recipe.name().to_owned()];
|
||||
for argument in arguments {
|
||||
invocation.push((*argument).to_string());
|
||||
}
|
||||
|
||||
ran.insert(invocation);
|
||||
Ok(())
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ mod quiet;
|
||||
mod quote;
|
||||
mod readme;
|
||||
mod regexes;
|
||||
mod run;
|
||||
mod search;
|
||||
mod shebang;
|
||||
mod shell;
|
||||
|
19
tests/run.rs
Normal file
19
tests/run.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use crate::common::*;
|
||||
|
||||
#[test]
|
||||
fn dont_run_duplicate_recipes() {
|
||||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
foo:
|
||||
# foo
|
||||
",
|
||||
)
|
||||
.args(&["foo", "foo"])
|
||||
.stderr(
|
||||
"
|
||||
# foo
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
Loading…
Reference in New Issue
Block a user