Skip duplicate recipe arguments (#1174)
This commit is contained in:
parent
8baebadd18
commit
db35a58a61
@ -284,6 +284,15 @@ impl<'src> Justfile<'src> {
|
|||||||
search: &Search,
|
search: &Search,
|
||||||
ran: &mut BTreeSet<Vec<String>>,
|
ran: &mut BTreeSet<Vec<String>>,
|
||||||
) -> RunResult<'src, ()> {
|
) -> 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(
|
let (outer, positional) = Evaluator::evaluate_parameters(
|
||||||
context.config,
|
context.config,
|
||||||
dotenv,
|
dotenv,
|
||||||
@ -300,20 +309,19 @@ impl<'src> Justfile<'src> {
|
|||||||
Evaluator::recipe_evaluator(context.config, dotenv, &scope, context.settings, search);
|
Evaluator::recipe_evaluator(context.config, dotenv, &scope, context.settings, search);
|
||||||
|
|
||||||
for Dependency { recipe, arguments } in recipe.dependencies.iter().take(recipe.priors) {
|
for Dependency { recipe, arguments } in recipe.dependencies.iter().take(recipe.priors) {
|
||||||
let mut invocation = vec![recipe.name().to_owned()];
|
let arguments = arguments
|
||||||
|
.iter()
|
||||||
|
.map(|argument| evaluator.evaluate_expression(argument))
|
||||||
|
.collect::<RunResult<Vec<String>>>()?;
|
||||||
|
|
||||||
for argument in arguments {
|
self.run_recipe(
|
||||||
invocation.push(evaluator.evaluate_expression(argument)?);
|
context,
|
||||||
}
|
recipe,
|
||||||
|
&arguments.iter().map(String::as_ref).collect::<Vec<&str>>(),
|
||||||
if !ran.contains(&invocation) {
|
dotenv,
|
||||||
let arguments = invocation
|
search,
|
||||||
.iter()
|
ran,
|
||||||
.skip(1)
|
)?;
|
||||||
.map(String::as_ref)
|
|
||||||
.collect::<Vec<&str>>();
|
|
||||||
self.run_recipe(context, recipe, &arguments, dotenv, search, ran)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
recipe.run(context, dotenv, scope.child(), search, &positional)?;
|
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);
|
ran.insert(invocation);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ mod quiet;
|
|||||||
mod quote;
|
mod quote;
|
||||||
mod readme;
|
mod readme;
|
||||||
mod regexes;
|
mod regexes;
|
||||||
|
mod run;
|
||||||
mod search;
|
mod search;
|
||||||
mod shebang;
|
mod shebang;
|
||||||
mod shell;
|
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