nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: casey/just
Pull request #2382 (2024-09-21 03:52:17)

Default values may reference earlier parameters


Patch:
diff --git a/src/recipe_resolver.rs b/src/recipe_resolver.rs
index c56afeaf..936b76ed 100644
--- a/src/recipe_resolver.rs
+++ b/src/recipe_resolver.rs
@@ -23,10 +23,10 @@ impl<'src: 'run, 'run> RecipeResolver<'src, 'run> {
     }
 
     for recipe in resolver.resolved_recipes.values() {
-      for parameter in &recipe.parameters {
+      for (i, parameter) in recipe.parameters.iter().enumerate() {
         if let Some(expression) = &parameter.default {
           for variable in expression.variables() {
-            resolver.resolve_variable(&variable, &[])?;
+            resolver.resolve_variable(&variable, &recipe.parameters[..i])?;
           }
         }
       }
@@ -63,11 +63,12 @@ impl<'src: 'run, 'run> RecipeResolver<'src, 'run> {
     parameters: &[Parameter],
   ) -> CompileResult<'src> {
     let name = variable.lexeme();
-    let undefined = !self.assignments.contains_key(name)
-      && !parameters.iter().any(|p| p.name.lexeme() == name)
-      && !constants().contains_key(name);
 
-    if undefined {
+    let defined = self.assignments.contains_key(name)
+      || parameters.iter().any(|p| p.name.lexeme() == name)
+      || constants().contains_key(name);
+
+    if !defined {
       return Err(variable.error(UndefinedVariable { variable: name }));
     }
 


Test patch:
diff --git a/tests/lib.rs b/tests/lib.rs
index 73f68fb9..681207f3 100644
--- a/tests/lib.rs
+++ b/tests/lib.rs
@@ -82,6 +82,7 @@ mod no_cd;
 mod no_dependencies;
 mod no_exit_message;
 mod os_attributes;
+mod parameters;
 mod parser;
 mod positional_arguments;
 mod private;
diff --git a/tests/misc.rs b/tests/misc.rs
index b4c25637..590c13cd 100644
--- a/tests/misc.rs
+++ b/tests/misc.rs
@@ -1941,26 +1941,6 @@ test! {
   shell: false,
 }
 
-test! {
-  name: parameter_cross_reference_error,
-  justfile: "
-    foo:
-
-    bar a b=a:
-  ",
-  args: (),
-  stdout: "",
-  stderr: "
-    error: Variable `a` not defined
-     ——▶ justfile:3:9
-      │
-    3 │ bar a b=a:
-      │         ^
-  ",
-  status: EXIT_FAILURE,
-  shell: false,
-}
-
 #[cfg(windows)]
 test! {
   name: pwsh_invocation_directory,
diff --git a/tests/parameters.rs b/tests/parameters.rs
new file mode 100644
index 00000000..8cf93ba1
--- /dev/null
+++ b/tests/parameters.rs
@@ -0,0 +1,38 @@
+use super::*;
+
+#[test]
+fn parameter_default_values_may_use_earlier_parameters() {
+  Test::new()
+    .justfile(
+      "
+        @foo a b=a:
+          echo {{ b }}
+      ",
+    )
+    .args(["foo", "bar"])
+    .stdout("bar\n")
+    .run();
+}
+
+#[test]
+fn parameter_default_values_may_not_use_later_parameters() {
+  Test::new()
+    .justfile(
+      "
+        @foo a b=c c='':
+          echo {{ b }}
+      ",
+    )
+    .args(["foo", "bar"])
+    .stderr(
+      "
+        error: Variable `c` not defined
+         ——▶ justfile:1:10
+          │
+        1 │ @foo a b=c c='':
+          │          ^
+      ",
+    )
+    .status(EXIT_FAILURE)
+    .run();
+}
Repository: casey/just
Pull request #1451 (2022-12-15 21:05:10)

Format exported variadic parameters correctly


Patch:
diff --git a/src/parameter.rs b/src/parameter.rs
index fb55d2cd..e065534a 100644
--- a/src/parameter.rs
+++ b/src/parameter.rs
@@ -15,12 +15,12 @@ pub(crate) struct Parameter<'src> {
 
 impl<'src> ColorDisplay for Parameter<'src> {
   fn fmt(&self, f: &mut Formatter, color: Color) -> Result<(), fmt::Error> {
-    if self.export {
-      write!(f, "$")?;
-    }
     if let Some(prefix) = self.kind.prefix() {
       write!(f, "{}", color.annotation().paint(prefix))?;
     }
+    if self.export {
+      write!(f, "$")?;
+    }
     write!(f, "{}", color.parameter().paint(self.name.lexeme()))?;
     if let Some(ref default) = self.default {
       write!(f, "={}", color.string().paint(&default.to_string()))?;


Test patch:
diff --git a/tests/fmt.rs b/tests/fmt.rs
index e4c46874..348cb27f 100644
--- a/tests/fmt.rs
+++ b/tests/fmt.rs
@@ -1042,3 +1042,12 @@ test! {
         echo foo
   ",
 }
+
+#[test]
+fn exported_parameter() {
+  Test::new()
+    .justfile("foo +$f:")
+    .args(&["--dump"])
+    .stdout("foo +$f:\n")
+    .run();
+}
Repository: casey/just
Pull request #1457 (2022-12-21 04:53:58)

Suppress --fmt --check diff if --quiet is passed


Patch:
diff --git a/src/subcommand.rs b/src/subcommand.rs
index 449f1009..be36912b 100644
--- a/src/subcommand.rs
+++ b/src/subcommand.rs
@@ -374,21 +374,23 @@ impl Subcommand {
       return if formatted == src {
         Ok(())
       } else {
-        use similar::{ChangeTag, TextDiff};
-
-        let diff = TextDiff::configure()
-          .algorithm(similar::Algorithm::Patience)
-          .diff_lines(src, &formatted);
-
-        for op in diff.ops() {
-          for change in diff.iter_changes(op) {
-            let (symbol, color) = match change.tag() {
-              ChangeTag::Delete => ("-", config.color.stderr().diff_deleted()),
-              ChangeTag::Equal => (" ", config.color.stderr()),
-              ChangeTag::Insert => ("+", config.color.stderr().diff_added()),
-            };
-
-            eprint!("{}{symbol}{change}{}", color.prefix(), color.suffix());
+        if !config.verbosity.quiet() {
+          use similar::{ChangeTag, TextDiff};
+
+          let diff = TextDiff::configure()
+            .algorithm(similar::Algorithm::Patience)
+            .diff_lines(src, &formatted);
+
+          for op in diff.ops() {
+            for change in diff.iter_changes(op) {
+              let (symbol, color) = match change.tag() {
+                ChangeTag::Delete => ("-", config.color.stderr().diff_deleted()),
+                ChangeTag::Equal => (" ", config.color.stderr()),
+                ChangeTag::Insert => ("+", config.color.stderr().diff_added()),
+              };
+
+              eprint!("{}{symbol}{change}{}", color.prefix(), color.suffix());
+            }
           }
         }
 


Test patch:
diff --git a/tests/fmt.rs b/tests/fmt.rs
index 348cb27f..3c972eda 100644
--- a/tests/fmt.rs
+++ b/tests/fmt.rs
@@ -53,6 +53,14 @@ test! {
   status: EXIT_FAILURE,
 }
 
+test! {
+  name: check_found_diff_quiet,
+  justfile: "x:=``\n",
+  args: ("--unstable", "--fmt", "--check", "--quiet"),
+  stderr: "",
+  status: EXIT_FAILURE,
+}
+
 test! {
   name: check_diff_color,
   justfile: "x:=``\n",
Repository: casey/just
Pull request #1539 (2023-01-27 14:57:26)

modify the default chooser to use `just --show` to preview
Overwrite `CHOOSER_DEFAULT`: `fzf` -> `fzf --preview 'just --show {}'`

![image](https://user-images.githubusercontent.com/65269574/215116875-36e6e4f1-f5b2-483e-ba9b-c403cd4212ac.png)


fzdwx: Ok, test case has been fixed.

1. `invoke_error_function` update regex
2. `default` use `--chooser fzf`

Patch:
diff --git a/Cargo.toml b/Cargo.toml
index a9d227c8..04a508fb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -52,6 +52,14 @@ temptree = "0.2.0"
 which = "4.0.0"
 yaml-rust = "0.4.5"
 
+[lib]
+doctest = false
+
+[[bin]]
+path = "src/main.rs"
+name = "just"
+test = false
+
 [features]
 # No features are active by default.
 default = []
diff --git a/man/just.1 b/man/just.1
index 74a294a2..d0a93935 100644
--- a/man/just.1
+++ b/man/just.1
@@ -19,7 +19,7 @@ Run `\-\-fmt` in 'check' mode. Exits with 0 if justfile is formatted correctly.
 .TP
 \fB\-\-choose\fR
 Select one or more recipes to run using a binary. If `\-\-chooser` is not passed the
-chooser defaults to the value of $JUST_CHOOSER, falling back to `fzf`
+chooser defaults to the value of $JUST_CHOOSER, falling back to `fzf --preview 'just --show {}'`
 .TP
 \fB\-\-clear\-shell\-args\fR
 Clear shell arguments
diff --git a/src/config.rs b/src/config.rs
index e6d5defc..069a9a8d 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -4,7 +4,7 @@ use {
 };
 
 // These three strings should be kept in sync:
-pub(crate) const CHOOSER_DEFAULT: &str = "fzf";
+pub(crate) const CHOOSER_DEFAULT: &str = "fzf --preview 'just --show {}'";
 pub(crate) const CHOOSER_ENVIRONMENT_KEY: &str = "JUST_CHOOSER";
 pub(crate) const CHOOSE_HELP: &str = "Select one or more recipes to run using a binary. If \
                                       `--chooser` is not passed the chooser defaults to the value \


Test patch:
diff --git a/tests/choose.rs b/tests/choose.rs
index 9dd0b19e..ed74638a 100644
--- a/tests/choose.rs
+++ b/tests/choose.rs
@@ -151,7 +151,9 @@ fn invoke_error_function() {
           echo bar
       ",
     )
-    .stderr_regex("error: Chooser `/ -cu fzf` invocation failed: .*\n")
+    .stderr_regex(
+      r"error: Chooser `/ -cu fzf --preview 'just --show \{\}'` invocation failed: .*\n",
+    )
     .status(EXIT_FAILURE)
     .shell(false)
     .args(["--shell", "/", "--choose"])
@@ -213,6 +215,7 @@ fn default() {
 
   let output = Command::new(executable_path("just"))
     .arg("--choose")
+    .arg("--chooser=fzf")
     .current_dir(tmp.path())
     .env("PATH", path)
     .output()
Repository: casey/just
Pull request #1547 (2023-02-09 06:18:43)

fix choose
> Select one or more recipes to run using a binary

Add `fzf` flag `-m`  to support select multiple command

casey: Nice! Tweaked it to use the long form of the flag, otherwise looks good.

Patch:
diff --git a/src/config.rs b/src/config.rs
index abd24cfd..70cb43fa 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -4,7 +4,7 @@ use {
 };
 
 // These three strings should be kept in sync:
-pub(crate) const CHOOSER_DEFAULT: &str = "fzf --preview 'just --show {}'";
+pub(crate) const CHOOSER_DEFAULT: &str = "fzf --multi --preview 'just --show {}'";
 pub(crate) const CHOOSER_ENVIRONMENT_KEY: &str = "JUST_CHOOSER";
 pub(crate) const CHOOSE_HELP: &str = "Select one or more recipes to run using a binary. If \
                                       `--chooser` is not passed the chooser defaults to the value \


Test patch:
diff --git a/tests/choose.rs b/tests/choose.rs
index ed74638a..153a7041 100644
--- a/tests/choose.rs
+++ b/tests/choose.rs
@@ -152,7 +152,7 @@ fn invoke_error_function() {
       ",
     )
     .stderr_regex(
-      r"error: Chooser `/ -cu fzf --preview 'just --show \{\}'` invocation failed: .*\n",
+      r"error: Chooser `/ -cu fzf --multi --preview 'just --show \{\}'` invocation failed: .*\n",
     )
     .status(EXIT_FAILURE)
     .shell(false)
Repository: casey/just
Pull request #1758 (2023-12-11 22:59:00)

Pass `--unstable` and `--color always` to fzf's default preview command
Pass `--unstable` to the preview command for the chooser, so that recipe previews can work even when the justfile relies on unstable features, such as `!include` directives.

Note that we're not taking the user by surprise by enabling unstable features in the preview: when the justfile includes unstable features, the user will need to pass `--unstable` explicitely to call `just --choose --unstable` already, or `just` will exit before launching the chooser.

Also tell `just`, in a second commit, to use colours for recipe previews.

casey: Nice, good change! Merging now.

Patch:
diff --git a/src/config.rs b/src/config.rs
index 9e8b7b92..b22e9190 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -4,7 +4,8 @@ use {
 };
 
 // These three strings should be kept in sync:
-pub(crate) const CHOOSER_DEFAULT: &str = "fzf --multi --preview 'just --show {}'";
+pub(crate) const CHOOSER_DEFAULT: &str =
+  "fzf --multi --preview 'just --unstable --color always --show {}'";
 pub(crate) const CHOOSER_ENVIRONMENT_KEY: &str = "JUST_CHOOSER";
 pub(crate) const CHOOSE_HELP: &str = "Select one or more recipes to run using a binary. If \
                                       `--chooser` is not passed the chooser defaults to the value \


Test patch:
diff --git a/tests/choose.rs b/tests/choose.rs
index ff224257..940fab0e 100644
--- a/tests/choose.rs
+++ b/tests/choose.rs
@@ -152,7 +152,7 @@ fn invoke_error_function() {
       ",
     )
     .stderr_regex(
-      r"error: Chooser `/ -cu fzf --multi --preview 'just --show \{\}'` invocation failed: .*\n",
+      r"error: Chooser `/ -cu fzf --multi --preview 'just --unstable --color always --show \{\}'` invocation failed: .*\n",
     )
     .status(EXIT_FAILURE)
     .shell(false)