nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: casey/just
Pull request #1243 (2022-06-21 00:20:36)

Fix multibyte codepoint crash
Found by @evanrichter!


Patch:
diff --git a/src/unindent.rs b/src/unindent.rs
index 4dcc5664..cec9200a 100644
--- a/src/unindent.rs
+++ b/src/unindent.rs
@@ -5,7 +5,7 @@ pub fn unindent(text: &str) -> String {
   let mut start = 0;
   for (i, c) in text.char_indices() {
     if c == '\n' || i == text.len() - c.len_utf8() {
-      let end = i + 1;
+      let end = i + c.len_utf8();
       lines.push(&text[start..end]);
       start = end;
     }


Test patch:
diff --git a/tests/lib.rs b/tests/lib.rs
index f5076798..0827bba5 100644
--- a/tests/lib.rs
+++ b/tests/lib.rs
@@ -57,6 +57,7 @@ mod invocation_directory;
 mod json;
 mod line_prefixes;
 mod misc;
+mod multibyte_char;
 mod positional_arguments;
 mod quiet;
 mod quote;
diff --git a/tests/multibyte_char.rs b/tests/multibyte_char.rs
new file mode 100644
index 00000000..2d658317
--- /dev/null
+++ b/tests/multibyte_char.rs
@@ -0,0 +1,6 @@
+use super::*;
+
+#[test]
+fn bugfix() {
+  Test::new().justfile("foo:\nx := '''ǩ'''").run();
+}
Repository: casey/just
Pull request #1348 (2022-09-21 05:39:43)

Allow fallback when search directory is provided
This loosens a restriction, and allows falling back to a justfile in a parent justfile when a search directory is provide, e.g. with `just ..` or `just foo/bar/`. Looking at it now, I can't really think of why I enforced that restriction in the first place 🤷‍♀️.


Patch:
diff --git a/src/subcommand.rs b/src/subcommand.rs
index 7174f367..90f1bf3e 100644
--- a/src/subcommand.rs
+++ b/src/subcommand.rs
@@ -92,8 +92,19 @@ impl Subcommand {
     arguments: &[String],
     overrides: &BTreeMap<String, String>,
   ) -> Result<(), Error<'src>> {
-    if config.unstable && config.search_config == SearchConfig::FromInvocationDirectory {
-      let mut path = config.invocation_directory.clone();
+    if config.unstable
+      && matches!(
+        config.search_config,
+        SearchConfig::FromInvocationDirectory | SearchConfig::FromSearchDirectory { .. }
+      )
+    {
+      let mut path = match &config.search_config {
+        SearchConfig::FromInvocationDirectory => config.invocation_directory.clone(),
+        SearchConfig::FromSearchDirectory { search_directory } => std::env::current_dir()
+          .unwrap()
+          .join(search_directory.clone()),
+        _ => unreachable!(),
+      };
 
       let mut unknown_recipes_errors = None;
 


Test patch:
diff --git a/tests/fall_back_to_parent.rs b/tests/fall_back_to_parent.rs
index af6ee4f0..a5d03cfa 100644
--- a/tests/fall_back_to_parent.rs
+++ b/tests/fall_back_to_parent.rs
@@ -83,7 +83,7 @@ fn requires_unstable() {
 }
 
 #[test]
-fn doesnt_work_with_search_directory() {
+fn works_with_provided_search_directory() {
   Test::new()
     .tree(tree! {
       bar: {
@@ -100,9 +100,15 @@ fn doesnt_work_with_search_directory() {
     ",
     )
     .args(&["--unstable", "./foo"])
+    .stdout("root\n")
+    .stderr(format!(
+      "
+      Trying ..{}justfile
+      echo root
+    ",
+      MAIN_SEPARATOR
+    ))
     .current_dir("bar")
-    .status(EXIT_FAILURE)
-    .stderr("error: Justfile does not contain recipe `foo`.\n")
     .run();
 }