nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: cobalt-org/liquid-rust
Pull request #78 (2017-02-26 22:43:10)

Only capitalize the first character
According to https://shopify.github.io/liquid/filters/capitalize/, the `capitalize` filter should only capitalize the first character.


Patch:
diff --git a/src/filters.rs b/src/filters.rs
index 6882005..120e9bf 100644
--- a/src/filters.rs
+++ b/src/filters.rs
@@ -75,20 +75,13 @@ pub fn downcase(input: &Value, _args: &[Value]) -> FilterResult {
 pub fn capitalize(input: &Value, _args: &[Value]) -> FilterResult {
     match *input {
         Str(ref s) => {
-            Ok(Str(s.char_indices().fold(String::new(), |word, (_, chr)| {
-                let next_char = match word.chars().last() {
-                        Some(last) => {
-                            if last.is_whitespace() {
-                                chr.to_uppercase().next().unwrap()
-                            } else {
-                                chr
-                            }
-                        }
-                        _ => chr.to_uppercase().next().unwrap(),
-                    }
-                    .to_string();
-                word + &next_char
-            })))
+            let mut chars = s.chars();
+            let capitalized = match chars.next() {
+                Some(first_char) => first_char.to_uppercase().chain(chars).collect(),
+                None => String::new(),
+            };
+
+            Ok(Str(capitalized))
         }
         _ => Err(InvalidType("String expected".to_owned())),
     }
@@ -582,16 +575,18 @@ mod tests {
     fn unit_capitalize() {
         assert_eq!(unit!(capitalize, tos!("abc")), tos!("Abc"));
         assert_eq!(unit!(capitalize, tos!("hello world 21")),
-                   tos!("Hello World 21"));
+                   tos!("Hello world 21"));
 
         // sure that Umlauts work
         assert_eq!(unit!(capitalize, tos!("über ètat, y̆es?")),
-                   tos!("Über Ètat, Y\u{306}es?"));
+                   tos!("Über ètat, y̆es?"));
 
         // Weird UTF-8 White space is kept – this is a no-break whitespace!
         assert_eq!(unit!(capitalize, tos!("hello world​")),
-                   tos!("Hello World​"));
+                   tos!("Hello world​"));
 
+        // The uppercase version of some character are more than one character long
+        assert_eq!(unit!(capitalize, tos!("ßß")), tos!("SSß"));
     }
 
     #[test]


Test patch:
diff --git a/tests/filters.rs b/tests/filters.rs
index 8290a1e..35c978b 100644
--- a/tests/filters.rs
+++ b/tests/filters.rs
@@ -43,7 +43,7 @@ pub fn capitalize() {
     data.set_val("text", Value::Str("hello world".to_string()));
 
     let output = template.render(&mut data);
-    assert_eq!(output.unwrap(), Some("Hello World".to_string()));
+    assert_eq!(output.unwrap(), Some("Hello world".to_string()));
 }
 
 #[test]
Repository: cocogitto/cocogitto
Pull request #333 (2023-10-28 23:57:54)

fix: correctly handle bump with pre-release tags


Patch:
diff --git a/src/git/tag.rs b/src/git/tag.rs
index e2d7409..7c56bd2 100644
--- a/src/git/tag.rs
+++ b/src/git/tag.rs
@@ -57,6 +57,7 @@ impl Repository {
         let tags: Vec<Tag> = self.all_tags()?;
         tags.into_iter()
             .filter(|tag| tag.package.is_none())
+            .filter(|tag| tag.version.pre.is_empty())
             .max()
             .ok_or(TagError::NoTag)
     }
@@ -176,7 +177,7 @@ impl Tag {
         self.oid.as_ref()
     }
 
-    pub(crate) fn from_str(raw: &str, oid: Option<Oid>) -> Result<Tag, TagError> {
+    pub fn from_str(raw: &str, oid: Option<Oid>) -> Result<Tag, TagError> {
         let prefix = SETTINGS.tag_prefix.as_ref();
 
         let package_tag: Option<Tag> = SETTINGS


Test patch:
diff --git a/tests/helpers.rs b/tests/helpers.rs
index 52446f4..018a660 100644
--- a/tests/helpers.rs
+++ b/tests/helpers.rs
@@ -8,6 +8,7 @@ use speculoos::assert_that;
 use speculoos::iter::ContainingIntoIterAssertions;
 use speculoos::option::OptionAssertions;
 
+use cocogitto::git::tag::Tag;
 use cocogitto::settings::{MonoRepoPackage, Settings};
 use cocogitto::CONFIG_PATH;
 
@@ -118,7 +119,14 @@ pub fn assert_tag_does_not_exist(tag: &str) -> Result<()> {
 
 pub fn assert_latest_tag(tag: &str) -> Result<()> {
     let tags = run_fun!(git --no-pager tag)?;
-    let tags: Vec<&str> = tags.split('\n').collect();
+    let tag = Tag::from_str(tag, None)?;
+    let mut tags: Vec<Tag> = tags
+        .split('\n')
+        .filter_map(|tag| Tag::from_str(tag, None).ok())
+        .collect();
+
+    tags.sort();
+
     assert_that!(tags.last()).is_some().is_equal_to(&tag);
     Ok(())
 }
diff --git a/tests/lib_tests/bump.rs b/tests/lib_tests/bump.rs
index 9c06609..698d234 100644
--- a/tests/lib_tests/bump.rs
+++ b/tests/lib_tests/bump.rs
@@ -332,6 +332,37 @@ fn should_fallback_to_0_0_0_when_there_is_no_tag() -> Result<()> {
     Ok(())
 }
 
+#[sealed_test]
+fn should_ignore_latest_prerelease_tag() -> Result<()> {
+    // Arrange
+    git_init()?;
+    git_commit("chore: first commit")?;
+    git_commit("feat: add a feature commit")?;
+
+    let mut cocogitto = CocoGitto::get()?;
+    cocogitto.create_version(
+        IncrementCommand::Auto,
+        Some("alpha1"),
+        None,
+        None,
+        false,
+        None,
+        false,
+    )?;
+
+    git_commit("feat: more features")?;
+    // Act
+    let result =
+        cocogitto.create_version(IncrementCommand::Auto, None, None, None, false, None, false);
+
+    // Assert
+    assert_that!(result).is_ok();
+    assert_tag_exists("0.1.0-alpha1")?;
+    assert_latest_tag("0.1.0")?;
+
+    Ok(())
+}
+
 #[sealed_test]
 fn auto_bump_package_only_ok() -> Result<()> {
     // Arrange