nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: mikefarah/yq
Pull request #133 (2018-04-08 08:37:56)

Rename to yq
Change `yq --version` output from `yaml version 1.14.1` to `yq version 1.14.1`

mikefarah: Nice but don't forget the tests 
hobti01: Thanks for the reminder, I didn't notice the command test.
mikefarah: cheer @hobti01 👍 

Patch:
diff --git a/version.go b/version.go
index 9218e802..c9408103 100644
--- a/version.go
+++ b/version.go
@@ -20,7 +20,7 @@ var (
 )
 
 // ProductName is the name of the product
-const ProductName = "yaml"
+const ProductName = "yq"
 
 // GetVersionDisplay composes the parts of the version in a way that's suitable
 // for displaying to humans.


Test patch:
diff --git a/commands_test.go b/commands_test.go
index b14ccd08..20e78960 100644
--- a/commands_test.go
+++ b/commands_test.go
@@ -103,7 +103,7 @@ func TestRootCmd_VersionShort(t *testing.T) {
 	if result.Error != nil {
 		t.Error(result.Error)
 	}
-	if !strings.Contains(result.Output, "yaml version") {
+	if !strings.Contains(result.Output, "yq version") {
 		t.Error("expected version message to be printed out, but the message was not found.")
 	}
 }
@@ -114,7 +114,7 @@ func TestRootCmd_VersionLong(t *testing.T) {
 	if result.Error != nil {
 		t.Error(result.Error)
 	}
-	if !strings.Contains(result.Output, "yaml version") {
+	if !strings.Contains(result.Output, "yq version") {
 		t.Error("expected version message to be printed out, but the message was not found.")
 	}
 }
Repository: mikefarah/yq
Pull request #1013 (2021-11-24 05:45:57)

Add log accessor
I was looking for the fix for https://github.com/mikefarah/yq/issues/432 and noticed @carolynvs had addressed it in her fork.  Had to fork myself to fix a minor merge conflict.

mikefarah: Still has a merge conflict sorry!
rjferguson21: Should be good now.

Patch:
diff --git a/pkg/yqlib/lib.go b/pkg/yqlib/lib.go
index b40c519e..0139ca58 100644
--- a/pkg/yqlib/lib.go
+++ b/pkg/yqlib/lib.go
@@ -15,6 +15,11 @@ import (
 
 var log = logging.MustGetLogger("yq-lib")
 
+// GetLogger returns the yq logger instance.
+func GetLogger() *logging.Logger {
+	return log
+}
+
 type operationType struct {
 	Type       string
 	NumArgs    uint // number of arguments to the op


Test patch:
diff --git a/pkg/yqlib/lib_test.go b/pkg/yqlib/lib_test.go
new file mode 100644
index 00000000..810a0611
--- /dev/null
+++ b/pkg/yqlib/lib_test.go
@@ -0,0 +1,10 @@
+package yqlib
+
+import "testing"
+
+func TestGetLogger(t *testing.T) {
+	l := GetLogger()
+	if l != log {
+		t.Fatal("GetLogger should return the yq logger instance, not a copy")
+	}
+}
Repository: mikefarah/yq
Pull request #1140 (2022-03-11 20:06:26)

handle `EvaluateNodes` nil panic
`EvaluateNodes` currently panics on a nil pointer here:
https://github.com/mikefarah/yq/blob/535799462f14cdb1c25e09f57381f86d8b95db66/pkg/yqlib/all_at_once_evaluator.go#L37

Fix for this is either:
*  checking for nil in `EvaluateCandidateNodes` 
*  calling `InitExpressionParser()` inside of `NewAllAtOnceEvaluator` (in this PR). 

Either approach is better than the current yqlib `NewAllAtOnceEvaluator` that leads to a footgun.


Patch:
diff --git a/pkg/yqlib/all_at_once_evaluator.go b/pkg/yqlib/all_at_once_evaluator.go
index 69c8c47c..066edd0d 100644
--- a/pkg/yqlib/all_at_once_evaluator.go
+++ b/pkg/yqlib/all_at_once_evaluator.go
@@ -22,6 +22,7 @@ type allAtOnceEvaluator struct {
 }
 
 func NewAllAtOnceEvaluator() Evaluator {
+	InitExpressionParser()
 	return &allAtOnceEvaluator{treeNavigator: NewDataTreeNavigator()}
 }
 


Test patch:
diff --git a/pkg/yqlib/all_at_once_evaluator_test.go b/pkg/yqlib/all_at_once_evaluator_test.go
index 546e3d84..2e9abc43 100644
--- a/pkg/yqlib/all_at_once_evaluator_test.go
+++ b/pkg/yqlib/all_at_once_evaluator_test.go
@@ -31,7 +31,6 @@ var evaluateNodesScenario = []expressionScenario{
 }
 
 func TestAllAtOnceEvaluateNodes(t *testing.T) {
-	InitExpressionParser()
 	var evaluator = NewAllAtOnceEvaluator()
 	for _, tt := range evaluateNodesScenario {
 		node := test.ParseData(tt.document)
diff --git a/pkg/yqlib/expression_parser_test.go b/pkg/yqlib/expression_parser_test.go
index d31792eb..4c89d207 100644
--- a/pkg/yqlib/expression_parser_test.go
+++ b/pkg/yqlib/expression_parser_test.go
@@ -7,9 +7,7 @@ import (
 )
 
 func getExpressionParser() ExpressionParserInterface {
-	if ExpressionParser == nil {
-		ExpressionParser = newExpressionParser()
-	}
+	InitExpressionParser()
 	return ExpressionParser
 }