nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: rsteube/carapace
Pull request #849 (2023-07-27 16:46:55)

example: remove injection cmd


Patch:
diff --git a/example/cmd/injection.go b/example/cmd/injection.go
deleted file mode 100644
index 04ae4b6..0000000
--- a/example/cmd/injection.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package cmd
-
-import (
-	"github.com/rsteube/carapace"
-	"github.com/spf13/cobra"
-)
-
-var injectionCmd = &cobra.Command{
-	Use:     "injection",
-	Short:   "just trying to break things",
-	GroupID: "test",
-	Run:     func(cmd *cobra.Command, args []string) {},
-}
-
-func init() {
-	rootCmd.AddCommand(injectionCmd)
-
-	carapace.Gen(injectionCmd).PositionalCompletion(
-		carapace.ActionValues("$(echo fail)"),
-		carapace.ActionValues(`\$(echo fail)`),
-		carapace.ActionValues("`echo fail`"),
-		carapace.ActionValues(`"; echo fail #`),
-		carapace.ActionValues(`"| echo fail #`),
-		carapace.ActionValues(`"&& echo fail #`),
-		carapace.ActionValues(`\$(echo fail)`),
-		carapace.ActionValues(`\`),
-		carapace.ActionValues(`LAST POSITIONAL VALUE`),
-	)
-}
diff --git a/example/cmd/root.go b/example/cmd/root.go
index 5e1886c..433cae6 100644
--- a/example/cmd/root.go
+++ b/example/cmd/root.go
@@ -35,7 +35,6 @@ func init() {
 	rootCmd.AddGroup(
 		&cobra.Group{ID: "main", Title: "Main Commands"},
 		&cobra.Group{ID: "modifier", Title: "Modifier Commands"},
-		&cobra.Group{ID: "test", Title: "Test Commands"},
 		&cobra.Group{ID: "plugin", Title: "Plugin Commands"},
 	)
 


Test patch:
diff --git a/example/cmd/root_test.go b/example/cmd/root_test.go
index 7be4d9b..214f680 100644
--- a/example/cmd/root_test.go
+++ b/example/cmd/root_test.go
@@ -69,8 +69,8 @@ func TestRoot(t *testing.T) {
 					"modifier", "modifier example",
 				).Style(style.Yellow).Tag("modifier commands"),
 				carapace.ActionValuesDescribed(
-					"injection", "just trying to break things",
-				).Style(style.Magenta).Tag("test commands"),
+					"plugin", "dynamic plugin command",
+				).Style(style.Magenta).Tag("plugin commands"),
 				carapace.ActionValuesDescribed(
 					"chain", "shorthand chain",
 					"completion", "Generate the autocompletion script for the specified shell",
@@ -80,9 +80,6 @@ func TestRoot(t *testing.T) {
 					"multiparts", "multiparts example",
 					"special", "",
 				).Tag("other commands"),
-				carapace.ActionValuesDescribed(
-					"plugin", "dynamic plugin command",
-				).Style(style.Cyan).Tag("plugin commands"),
 			).ToA())
 
 		s.Run("a").
Repository: rsteube/carapace
Pull request #855 (2023-07-29 10:30:27)

lexer: quote workaround


Patch:
diff --git a/internal/lexer/lexer.go b/internal/lexer/lexer.go
index f2ead05..b51220d 100644
--- a/internal/lexer/lexer.go
+++ b/internal/lexer/lexer.go
@@ -23,15 +23,19 @@ type Tokenset struct {
 func Split(s string, pipelines bool) (*Tokenset, error) {
 	tokenset, err := split(s, pipelines)
 	if err != nil && err.Error() == "EOF found when expecting closing quote" {
-		tokenset, err = split(s+`"`, pipelines)
+		tokenset, err = split(s+`_"`, pipelines)
 		if err == nil {
 			tokenset.State = OPEN_DOUBLE
+			last := tokenset.Tokens[len(tokenset.Tokens)-1]
+			tokenset.Tokens[len(tokenset.Tokens)-1] = last[:len(last)-1]
 		}
 	}
 	if err != nil && err.Error() == "EOF found when expecting closing quote" {
-		tokenset, err = split(s+`'`, pipelines)
+		tokenset, err = split(s+`_'`, pipelines)
 		if err == nil {
 			tokenset.State = OPEN_SINGLE
+			last := tokenset.Tokens[len(tokenset.Tokens)-1]
+			tokenset.Tokens[len(tokenset.Tokens)-1] = last[:len(last)-1]
 		}
 	}
 	return tokenset, err


Test patch:
diff --git a/internal/lexer/lexer_test.go b/internal/lexer/lexer_test.go
index b55063f..77bf2b8 100644
--- a/internal/lexer/lexer_test.go
+++ b/internal/lexer/lexer_test.go
@@ -150,7 +150,6 @@ func TestSplit(t *testing.T) {
 		State:  OPEN_DOUBLE,
 	})
 
-	t.Skip("skipping test that don't work yet") // TODO these need to work
 	_test(`example "`, Tokenset{
 		Tokens: []string{"example", ""},
 		Prefix: `example `,
Repository: rsteube/carapace
Pull request #873 (2023-08-01 06:02:51)

lexer: remove escape character when EOF follows (lenient)


Patch:
diff --git a/internal/lexer/lexer.go b/internal/lexer/lexer.go
index b51220d..84b9f6a 100644
--- a/internal/lexer/lexer.go
+++ b/internal/lexer/lexer.go
@@ -22,6 +22,9 @@ type Tokenset struct {
 
 func Split(s string, pipelines bool) (*Tokenset, error) {
 	tokenset, err := split(s, pipelines)
+	if err != nil && err.Error() == "EOF found after escape character" {
+		return Split(s[:len(s)-1], pipelines) // TODO mark this in tokenset
+	}
 	if err != nil && err.Error() == "EOF found when expecting closing quote" {
 		tokenset, err = split(s+`_"`, pipelines)
 		if err == nil {


Test patch:
diff --git a/internal/lexer/lexer_test.go b/internal/lexer/lexer_test.go
index 77bf2b8..1f52d0b 100644
--- a/internal/lexer/lexer_test.go
+++ b/internal/lexer/lexer_test.go
@@ -161,4 +161,9 @@ func TestSplit(t *testing.T) {
 		Prefix: `example `,
 		State:  OPEN_SINGLE,
 	})
+
+	_test(`example \`, Tokenset{
+		Tokens: []string{"example", ""},
+		Prefix: `example `,
+	})
 }
Repository: rsteube/carapace
Pull request #904 (2023-08-15 20:33:01)

elvish: use peach


Patch:
diff --git a/internal/shell/elvish/snippet.go b/internal/shell/elvish/snippet.go
index 9c5a8b6..a06f338 100644
--- a/internal/shell/elvish/snippet.go
+++ b/internal/shell/elvish/snippet.go
@@ -18,7 +18,7 @@ func Snippet(cmd *cobra.Command) string {
 		if (not-eq $completion[Usage] "") {
 			edit:notify (styled "usage: " $completion[DescriptionStyle])$completion[Usage]
 		}
-		put $completion[Candidates] | all (one) | each {|c|
+		put $completion[Candidates] | all (one) | peach {|c|
 			if (eq $c[Description] "") {
 		    	edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style]) &code-suffix=$c[CodeSuffix]
 			} else {


Test patch:
diff --git a/example/cmd/_test/elvish.elv b/example/cmd/_test/elvish.elv
index 0c54237..0e73651 100644
--- a/example/cmd/_test/elvish.elv
+++ b/example/cmd/_test/elvish.elv
@@ -6,7 +6,7 @@ set edit:completion:arg-completer[example] = {|@arg|
 		if (not-eq $completion[Usage] "") {
 			edit:notify (styled "usage: " $completion[DescriptionStyle])$completion[Usage]
 		}
-		put $completion[Candidates] | all (one) | each {|c|
+		put $completion[Candidates] | all (one) | peach {|c|
 			if (eq $c[Description] "") {
 		    	edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style]) &code-suffix=$c[CodeSuffix]
 			} else {
Repository: rsteube/carapace
Pull request #995 (2024-02-24 09:29:30)

added diff


Patch:
diff --git a/diff.go b/diff.go
new file mode 100644
index 0000000..b2021d9
--- /dev/null
+++ b/diff.go
@@ -0,0 +1,44 @@
+package carapace
+
+import (
+	"github.com/rsteube/carapace/internal/common"
+	"github.com/rsteube/carapace/pkg/style"
+)
+
+// Diff compares values of two actions.
+// It overrides the style to hightlight changes.
+//
+//	red:   only present in original
+//	dim:   present in both
+//	green: only present in new
+func Diff(original, new Action) Action {
+	return ActionCallback(func(c Context) Action {
+		invokedBatch := Batch(
+			original,
+			new,
+		).Invoke(c)
+
+		merged := make(map[string]common.RawValue)
+		for _, v := range invokedBatch[0].action.rawValues {
+			v.Style = style.Red
+			merged[v.Value] = v
+		}
+
+		for _, v := range invokedBatch[1].action.rawValues {
+			if _, ok := merged[v.Value]; ok {
+				v.Style = style.Dim
+				merged[v.Value] = v
+			} else {
+				v.Style = style.Green
+				merged[v.Value] = v
+			}
+		}
+
+		mergedBatch := invokedBatch.Merge()
+		mergedBatch.action.rawValues = make(common.RawValues, 0)
+		for _, v := range merged {
+			mergedBatch.action.rawValues = append(mergedBatch.action.rawValues, v)
+		}
+		return mergedBatch.ToA()
+	})
+}


Test patch:
diff --git a/diff_test.go b/diff_test.go
new file mode 100644
index 0000000..e348747
--- /dev/null
+++ b/diff_test.go
@@ -0,0 +1,27 @@
+package carapace
+
+import (
+	"testing"
+
+	"github.com/rsteube/carapace/pkg/style"
+)
+
+func TestDiff(t *testing.T) {
+	original := ActionValues(
+		"removed",
+		"same",
+	)
+	new := ActionValues(
+		"same",
+		"added",
+	)
+
+	assertEqual(t,
+		Diff(original, new).Invoke(NewContext()),
+		ActionStyledValues(
+			"removed", style.Red,
+			"same", style.Dim,
+			"added", style.Green,
+		).Invoke(NewContext()),
+	)
+}
Repository: CS-SI/eodag
Pull request #321 (2021-07-19 16:01:41)

fix: pystac v1.0 update
Fixes [CI failure](https://github.com/CS-SI/eodag/runs/3101522106) after [pystac v1.0](https://github.com/stac-utils/pystac/releases) update.

Note that [single-file-stac](https://github.com/stac-extensions/single-file-stac) has been removed from `pystac` as the extension is being rethought


Patch:
diff --git a/eodag/utils/stac_reader.py b/eodag/utils/stac_reader.py
index ef9fcd44..b3c166e6 100644
--- a/eodag/utils/stac_reader.py
+++ b/eodag/utils/stac_reader.py
@@ -33,7 +33,7 @@ HTTP_REQ_TIMEOUT = 5
 
 
 class _TextOpener:
-    """Exhaust read methods for pystac.STAC_IO in the order defined
+    """Exhaust read methods for pystac.StacIO in the order defined
     in the openers list"""
 
     def __init__(self, timeout):
@@ -117,7 +117,7 @@ def fetch_stac_items(
     # URI opener used by PySTAC internally, instantiated here
     # to retrieve the timeout.
     _text_opener = _TextOpener(timeout)
-    pystac.STAC_IO.read_text_method = _text_opener
+    pystac.StacIO.read_text = _text_opener
 
     stac_obj = pystac.read_file(stac_path)
     # Single STAC item
diff --git a/setup.py b/setup.py
index cc0db0eb..07dc033f 100755
--- a/setup.py
+++ b/setup.py
@@ -59,7 +59,7 @@ setup(
         "flask >= 1.0.2",
         "markdown >= 3.0.1",
         "whoosh",
-        "pystac",
+        "pystac >= 1.0.0b1",
     ],
     python_requires=">=3.6",
     extras_require={


Test patch:
diff --git a/tests/integration/test_search_stac_static.py b/tests/integration/test_search_stac_static.py
index dcf32cab..ee3483b0 100644
--- a/tests/integration/test_search_stac_static.py
+++ b/tests/integration/test_search_stac_static.py
@@ -160,6 +160,9 @@ class TestSearchStacStatic(unittest.TestCase):
         self.assertIn("foo", item[0].properties)
         self.assertEqual(item[0].properties["foo"], "descending")
 
+    @unittest.skip(
+        "skipped as single-file-stac has been removed and is being rethought"
+    )
     def test_search_stac_static_load_singlefile_catalog(self):
         """load_stac_items from child catalog must provide items"""
         items = self.dag.load_stac_items(
diff --git a/tests/units/test_stac_reader.py b/tests/units/test_stac_reader.py
index 21346fa2..5d89a559 100644
--- a/tests/units/test_stac_reader.py
+++ b/tests/units/test_stac_reader.py
@@ -71,6 +71,9 @@ class TestStacReader(unittest.TestCase):
         self.assertEqual(item[0]["type"], "Feature")
         self.assertEqual(item[0]["collection"], "S2_MSI_L1C")
 
+    @unittest.skip(
+        "skipped as single-file-stac has been removed and is being rethought"
+    )
     def test_stact_reader_fetch_singlefile_catalog(self):
         """fetch_stact_items must return all the items from a single file catalog"""
         items = fetch_stac_items(self.singlefile_cat)