nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: prebid/prebid-server
Pull request #1448 (2020-08-20 19:23:04)

Fixes bug


Patch:
diff --git a/exchange/exchange.go b/exchange/exchange.go
index 53f4a7a3..e465a783 100644
--- a/exchange/exchange.go
+++ b/exchange/exchange.go
@@ -76,6 +76,7 @@ type bidResponseWrapper struct {
 func NewExchange(client *http.Client, cache prebid_cache_client.Client, cfg *config.Configuration, metricsEngine pbsmetrics.MetricsEngine, infos adapters.BidderInfos, gDPR gdpr.Permissions, currencyConverter *currencies.RateConverter) Exchange {
 	e := new(exchange)
 
+	e.eeaCountries = make(map[string]struct{}, len(cfg.GDPR.EEACountries))
 	var s struct{}
 	for _, c := range cfg.GDPR.EEACountries {
 		e.eeaCountries[c] = s


Test patch:
diff --git a/exchange/exchange_test.go b/exchange/exchange_test.go
index aad448f3..a6f69f70 100644
--- a/exchange/exchange_test.go
+++ b/exchange/exchange_test.go
@@ -48,6 +48,9 @@ func TestNewExchange(t *testing.T) {
 			ExpectedTimeMillis: 20,
 		},
 		Adapters: blankAdapterConfig(openrtb_ext.BidderList()),
+		GDPR: config.GDPR{
+			EEACountries: []string{"FIN", "FRA", "GUF"},
+		},
 	}
 
 	currencyConverter := currencies.NewRateConverter(&http.Client{}, "", time.Duration(0))
Repository: scylladb/scylla-operator
Pull request #952 (2022-03-17 09:13:08)

Expose node-exporter metrics in Scylla Pods
Scylla image by defualt runs node-exporter which is exposing useful
metrics our Scylla Monitoring expects. Previously they weren't exposed
on Pod level hence Prometheus wans't able to scrape them.


Patch:
diff --git a/examples/common/monitoring/scylla-service-monitor.yaml b/examples/common/monitoring/scylla-service-monitor.yaml
index fe252e52c..72ee96ba8 100644
--- a/examples/common/monitoring/scylla-service-monitor.yaml
+++ b/examples/common/monitoring/scylla-service-monitor.yaml
@@ -11,6 +11,7 @@ spec:
     matchLabels:
       app: scylla
   endpoints:
+    - port: node-exporter
     - port: agent-prometheus
       metricRelabelings:
         # rename job label to 'manager_agent' due to hardcoded name
diff --git a/pkg/controller/scyllacluster/resource.go b/pkg/controller/scyllacluster/resource.go
index b11537fdf..ffc6adb1b 100644
--- a/pkg/controller/scyllacluster/resource.go
+++ b/pkg/controller/scyllacluster/resource.go
@@ -142,6 +142,10 @@ func memberServicePorts(cluster *scyllav1.ScyllaCluster) []corev1.ServicePort {
 			Name: "agent-api",
 			Port: 10001,
 		},
+		{
+			Name: "node-exporter",
+			Port: 9100,
+		},
 	}
 	if cluster.Spec.Alternator.Enabled() {
 		ports = append(ports, corev1.ServicePort{
@@ -495,6 +499,10 @@ func containerPorts(c *scyllav1.ScyllaCluster) []corev1.ContainerPort {
 			Name:          "prometheus",
 			ContainerPort: 9180,
 		},
+		{
+			Name:          "node-exporter",
+			ContainerPort: 9100,
+		},
 	}
 
 	if c.Spec.Alternator.Enabled() {


Test patch:
diff --git a/pkg/controller/scyllacluster/resource_test.go b/pkg/controller/scyllacluster/resource_test.go
index 51dfd0d14..eb5430552 100644
--- a/pkg/controller/scyllacluster/resource_test.go
+++ b/pkg/controller/scyllacluster/resource_test.go
@@ -90,6 +90,10 @@ func TestMemberService(t *testing.T) {
 			Name: "agent-api",
 			Port: 10001,
 		},
+		{
+			Name: "node-exporter",
+			Port: 9100,
+		},
 		{
 			Name: "thrift",
 			Port: 9160,
@@ -507,6 +511,10 @@ func TestStatefulSetForRack(t *testing.T) {
 										Name:          "prometheus",
 										ContainerPort: 9180,
 									},
+									{
+										Name:          "node-exporter",
+										ContainerPort: 9100,
+									},
 									{
 										Name:          "cql",
 										ContainerPort: 9042,
Repository: scylladb/scylla-operator
Pull request #1123 (2022-12-20 17:41:18)

Move scylla validation into its group folder
**Description of your changes:**
Validation belongs to its group. We need to fix this historical misplacement for  #1111




Patch:
diff --git a/pkg/cmd/operator/webhooks.go b/pkg/cmd/operator/webhooks.go
index 2a40ece1f..1017a4705 100644
--- a/pkg/cmd/operator/webhooks.go
+++ b/pkg/cmd/operator/webhooks.go
@@ -16,7 +16,7 @@ import (
 
 	"github.com/scylladb/scylla-operator/pkg/admissionreview"
 	scyllav1 "github.com/scylladb/scylla-operator/pkg/api/scylla/v1"
-	"github.com/scylladb/scylla-operator/pkg/api/validation"
+	"github.com/scylladb/scylla-operator/pkg/api/scylla/validation"
 	"github.com/scylladb/scylla-operator/pkg/genericclioptions"
 	"github.com/scylladb/scylla-operator/pkg/signals"
 	"github.com/scylladb/scylla-operator/pkg/version"


Test patch:
diff --git a/pkg/api/validation/cluster_validation.go b/pkg/api/scylla/validation/cluster_validation.go
similarity index 100%
rename from pkg/api/validation/cluster_validation.go
rename to pkg/api/scylla/validation/cluster_validation.go
diff --git a/pkg/api/validation/cluster_validation_test.go b/pkg/api/scylla/validation/cluster_validation_test.go
similarity index 99%
rename from pkg/api/validation/cluster_validation_test.go
rename to pkg/api/scylla/validation/cluster_validation_test.go
index 60946bd58..c6a270c16 100644
--- a/pkg/api/validation/cluster_validation_test.go
+++ b/pkg/api/scylla/validation/cluster_validation_test.go
@@ -6,7 +6,7 @@ import (
 
 	"github.com/google/go-cmp/cmp"
 	v1 "github.com/scylladb/scylla-operator/pkg/api/scylla/v1"
-	"github.com/scylladb/scylla-operator/pkg/api/validation"
+	"github.com/scylladb/scylla-operator/pkg/api/scylla/validation"
 	"github.com/scylladb/scylla-operator/pkg/test/unit"
 	corev1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/api/resource"
Repository: magefile/mage
Pull request #43 (2017-10-05 13:18:50)

Issue #30 - Added env check "MAGE_VERBOSE" to mage.

webRat: Actually hold off and I'll see if I can add a test too. :o

Related to Issue #43 
natefinch: can you check for 0/1 as well?  I would like MAGE_VERBOSE=1 to do the right thing.  Those monsters who use MAGE_VERBOSE=T can get stuffed, though.
webRat: I think I'm going to have to start over. The main.go file completely changed on me.

(╯°□°)╯︵ ┻━┻
natefinch: the new changes should make this a lot easier.  The logic is a lot more broken up into individual functions that can be unit tested.  So just throw this code in Parse... it'll make your life a lot easier.
webRat: 🙌

Patch:
diff --git a/.gitignore b/.gitignore
index e5e1eb6..31bacd2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,5 +13,8 @@
 # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
 .glide/
 
+# VScode
+.vscode
+
 # stupid osx
 .DS_Store
\ No newline at end of file
diff --git a/mage/main.go b/mage/main.go
index 7e3cff8..ca6510b 100644
--- a/mage/main.go
+++ b/mage/main.go
@@ -12,6 +12,7 @@ import (
 	"path/filepath"
 	"runtime"
 	"sort"
+	"strconv"
 	"strings"
 	"text/template"
 	"unicode"
@@ -129,6 +130,16 @@ func Parse(stdout io.Writer, args []string) (inv Invocation, mageInit, showVersi
 		// tell upstream, to just exit
 		return inv, mageInit, showVersion, flag.ErrHelp
 	}
+
+	// If verbose is still false, we're going to peek at the environment variable to see if
+	// MAGE_VERBOSE has been set. If so, we're going to use it for the value of MAGE_VERBOSE.
+	if inv.Verbose == false {
+		envVerbose, err := strconv.ParseBool(os.Getenv("MAGE_VERBOSE"))
+		if err == nil {
+			inv.Verbose = envVerbose
+		}
+	}
+
 	inv.Args = fs.Args()
 	return inv, mageInit, showVersion, err
 }


Test patch:
diff --git a/mage/main_test.go b/mage/main_test.go
index 5d8b690..514c448 100644
--- a/mage/main_test.go
+++ b/mage/main_test.go
@@ -84,6 +84,24 @@ func TestVerbose(t *testing.T) {
 	}
 }
 
+func TestVerboseEnv(t *testing.T) {
+	os.Setenv("MAGE_VERBOSE", "true")
+
+	stdout := &bytes.Buffer{}
+	inv, _, _, err := Parse(stdout, []string{})
+	if err != nil {
+		t.Fatal("unexpected error", err)
+	}
+
+	expected := true
+
+	if inv.Verbose != true {
+		t.Fatalf("expected %t, but got %t", expected, inv.Verbose)
+	}
+
+	os.Unsetenv("MAGE_VERBOSE")
+}
+
 func TestList(t *testing.T) {
 	stdout := &bytes.Buffer{}
 	inv := Invocation{
Repository: magefile/mage
Pull request #64 (2017-10-13 22:09:29)

log targets being run when mage is run with -v (#44)


Patch:
diff --git a/mage/template.go b/mage/template.go
index 2a5fc3a..2d30606 100644
--- a/mage/template.go
+++ b/mage/template.go
@@ -79,6 +79,9 @@ func main() {
 	switch strings.ToLower(os.Args[1]) {
 	{{range .Funcs -}}
 	case "{{lower .Name}}":
+		if os.Getenv("MAGEFILE_VERBOSE") != "" {
+			logger.Println("Running target:", "{{.Name}}")
+		}
 		{{if .IsError -}}
 			if err := {{.Name}}(); err != nil {
 				logger.Printf("Error: %v\n", err)


Test patch:
diff --git a/mage/main_test.go b/mage/main_test.go
index 00b95e8..97f05d4 100644
--- a/mage/main_test.go
+++ b/mage/main_test.go
@@ -80,7 +80,7 @@ func TestVerbose(t *testing.T) {
 	}
 
 	actual = stderr.String()
-	expected = "hi!\n"
+	expected = "Running target: TestVerbose\nhi!\n"
 	if actual != expected {
 		t.Fatalf("expected %q, but got %q", expected, actual)
 	}
Repository: magefile/mage
Pull request #175 (2018-09-20 18:27:14)

actually parse the MAGEFILE_VERBOSE flag
turns out that we weren't parsing the MAGEFILE_VERBOSE flag, we were just checking if it
was empty or not.  So if you set it to 0, the code would think you were turning on
verbose mode.  Note that this only really affected the use of the default log package
logger, so it was kind of hard to see.  Fixed now, at least.


Patch:
diff --git a/mage/main.go b/mage/main.go
index 5076054..dd4fef8 100644
--- a/mage/main.go
+++ b/mage/main.go
@@ -432,11 +432,11 @@ func Magefiles(magePath, goCmd string, stderr io.Writer, isDebug bool) ([]string
 	}
 	cmd.Dir = magePath
 	b, err = cmd.Output()
-	list = strings.TrimSpace(string(b))
-
 	if err != nil {
 		return fail(fmt.Errorf("failed to list mage gofiles: %v", err))
 	}
+
+	list = strings.TrimSpace(string(b))
 	files := []string{}
 	for _, f := range strings.Split(list, "||") {
 		if f != "" && !exclude[f] {
diff --git a/mage/template.go b/mage/template.go
index 6e27fe3..f24dcb5 100644
--- a/mage/template.go
+++ b/mage/template.go
@@ -102,7 +102,8 @@ func main() {
 	_ = handleError
 
 	log.SetFlags(0)
-	if os.Getenv("MAGEFILE_VERBOSE") == "" {
+	verbose, _ := strconv.ParseBool(os.Getenv("MAGEFILE_VERBOSE"))
+	if !verbose {
 		log.SetOutput(ioutil.Discard)
 	}
 	logger := log.New(os.Stderr, "", 0)
@@ -163,8 +164,6 @@ func main() {
 				os.Exit(1)
 		}	
 	}
-	// to avoid unused import
-	_ = strconv.ParseBool
 	if len(os.Args) < 2 {
 	{{- if .Default}}
 		ignore, _ := strconv.ParseBool(os.Getenv("MAGEFILE_IGNOREDEFAULT"))
@@ -196,7 +195,7 @@ func main() {
 		switch strings.ToLower(target) {
 		{{range .Funcs }}
 		case "{{lower .TemplateName}}":
-			if os.Getenv("MAGEFILE_VERBOSE") != "" {
+			if verbose {
 				logger.Println("Running target:", "{{.TemplateName}}")
 			}
 			{{.TemplateString}}


Test patch:
diff --git a/mage/main_test.go b/mage/main_test.go
index e8f80be..3854825 100644
--- a/mage/main_test.go
+++ b/mage/main_test.go
@@ -191,7 +191,19 @@ func TestVerboseEnv(t *testing.T) {
 	if inv.Verbose != true {
 		t.Fatalf("expected %t, but got %t ", expected, inv.Verbose)
 	}
+}
+func TestVerboseFalseEnv(t *testing.T) {
+	os.Setenv("MAGEFILE_VERBOSE", "0")
+	defer os.Unsetenv("MAGEFILE_VERBOSE")
+	stdout := &bytes.Buffer{}
+	code := ParseAndRun(ioutil.Discard, stdout, nil, []string{"-d", "testdata", "testverbose"})
+	if code != 0 {
+		t.Fatal("unexpected code", code)
+	}
 
+	if stdout.String() != "" {
+		t.Fatalf("expected no output, but got %s", stdout.String())
+	}
 }
 
 func TestList(t *testing.T) {
Repository: magefile/mage
Pull request #212 (2018-12-22 05:59:26)

Sort target list when using mage:import
I was trying out the `mage:import` feature which is wonderful in helping reduce duplication in our monorepo. I thought it would nice to have all targets sorted when using this feature.

natefinch: This is great, thanks!

Patch:
diff --git a/mage/template.go b/mage/template.go
index 7b9bd6f..dc943fd 100644
--- a/mage/template.go
+++ b/mage/template.go
@@ -15,6 +15,7 @@ import (
 	"log"
 	"os"
 	"path/filepath"
+	"sort"
 	"strconv"
 	"strings"
 	"text/tabwriter"
@@ -96,16 +97,28 @@ Options:
 		{{with .Description}}fmt.Println(` + "`{{.}}\n`" + `)
 		{{- end}}
 		{{- $default := .DefaultFunc}}
-		w := tabwriter.NewWriter(os.Stdout, 0, 4, 4, ' ', 0)
-		fmt.Println("Targets:")
+		targets := map[string]string{
 		{{- range .Funcs}}
-			fmt.Fprintln(w, "  {{lowerFirst .TargetName}}{{if and (eq .Name $default.Name) (eq .Receiver $default.Receiver)}}*{{end}}\t" + {{printf "%q" .Synopsis}})
+			"{{lowerFirst .TargetName}}{{if and (eq .Name $default.Name) (eq .Receiver $default.Receiver)}}*{{end}}": {{printf "%q" .Synopsis}},
 		{{- end}}
 		{{- range .Imports}}{{$imp := .}}
 			{{- range .Info.Funcs}}
-			fmt.Fprintln(w, "  {{lowerFirst .TargetName}}{{if and (eq .Name $default.Name) (eq .Receiver $default.Receiver)}}*{{end}}\t" + {{printf "%q" .Synopsis}})
-			{{end}}
+			"{{lowerFirst .TargetName}}{{if and (eq .Name $default.Name) (eq .Receiver $default.Receiver)}}*{{end}}": {{printf "%q" .Synopsis}},
+			{{- end}}
 		{{- end}}
+		}
+
+		keys := make([]string, 0, len(targets))
+		for name := range targets {
+			keys = append(keys, name)
+		}
+		sort.Strings(keys)
+
+		fmt.Println("Targets:")
+		w := tabwriter.NewWriter(os.Stdout, 0, 4, 4, ' ', 0)
+		for _, name := range keys {
+			fmt.Fprintf(w, "  %v\t%v\n", name, targets[name])
+		}
 		err := w.Flush()
 		{{- if .DefaultFunc.Name}}
 			if err == nil {


Test patch:
diff --git a/mage/import_test.go b/mage/import_test.go
index bbb64d3..c24b852 100644
--- a/mage/import_test.go
+++ b/mage/import_test.go
@@ -22,11 +22,11 @@ func TestMageImportsList(t *testing.T) {
 	actual := stdout.String()
 	expected := `
 Targets:
+  buildSubdir        Builds stuff.
+  nS:deploy          deploys stuff.
   root               
-  zz:nS:deploy2*     deploys stuff.
   zz:buildSubdir2    Builds stuff.
-  nS:deploy          deploys stuff.
-  buildSubdir        Builds stuff.
+  zz:nS:deploy2*     deploys stuff.
 
 * default target
 `[1:]
Repository: magefile/mage
Pull request #525 (2025-06-15 13:37:56)

add the ability to call targets with float64 args
This was something that should have been done forever ago.


Patch:
diff --git a/parse/parse.go b/parse/parse.go
index e68703b..c64e7cc 100644
--- a/parse/parse.go
+++ b/parse/parse.go
@@ -128,6 +128,14 @@ func (f Function) ExecCode() string {
 					os.Exit(2)
 				}
 				x++`, x)
+		case "float64":
+			parseargs += fmt.Sprintf(`
+				arg%d, err := strconv.ParseFloat(args.Args[x], 64)
+				if err != nil {
+					logger.Printf("can't convert argument %%q to float64\n", args.Args[x])
+					os.Exit(2)
+				}
+				x++`, x)
 		case "bool":
 			parseargs += fmt.Sprintf(`
 				arg%d, err := strconv.ParseBool(args.Args[x])
@@ -845,6 +853,7 @@ func toOneLine(s string) string {
 var argTypes = map[string]string{
 	"string":           "string",
 	"int":              "int",
+	"float64":          "float64",
 	"&{time Duration}": "time.Duration",
 	"bool":             "bool",
 }


Test patch:
diff --git a/mage/args_test.go b/mage/args_test.go
index 6997df8..d8ef8ab 100644
--- a/mage/args_test.go
+++ b/mage/args_test.go
@@ -12,12 +12,12 @@ func TestArgs(t *testing.T) {
 		Dir:    "./testdata/args",
 		Stderr: stderr,
 		Stdout: stdout,
-		Args:   []string{"status", "say", "hi", "bob", "count", "5", "status", "wait", "5ms", "cough", "false"},
+		Args:   []string{"status", "say", "hi", "bob", "count", "5", "status", "wait", "5ms", "cough", "false", "doubleIt", "3.1"},
 	}
 	code := Invoke(inv)
 	if code != 0 {
 		t.Log(stderr.String())
-		t.Fatalf("expected 1, but got %v", code)
+		t.Fatalf("expected 0, but got %v", code)
 	}
 	actual := stdout.String()
 	expected := `status
@@ -26,6 +26,7 @@ saying hi bob
 status
 waiting 5ms
 not coughing
+3.1 * 2 = 6.2
 `
 	if actual != expected {
 		t.Fatalf("output is not expected:\n%q", actual)
@@ -101,6 +102,29 @@ func TestBadDurationArg(t *testing.T) {
 	}
 }
 
+func TestBadFloat64Arg(t *testing.T) {
+	stderr := &bytes.Buffer{}
+	stdout := &bytes.Buffer{}
+	inv := Invocation{
+		Dir:    "./testdata/args",
+		Stderr: stderr,
+		Stdout: stdout,
+		Args:   []string{"doubleIt", "abc123"},
+	}
+	code := Invoke(inv)
+	if code != 2 {
+		t.Log("stderr:", stderr)
+		t.Log("stdout:", stdout)
+		t.Fatalf("expected code 2, but got %v", code)
+	}
+	actual := stderr.String()
+	expected := "can't convert argument \"abc123\" to float64\n"
+
+	if actual != expected {
+		t.Fatalf("output is not expected:\n%q", actual)
+	}
+}
+
 func TestMissingArgs(t *testing.T) {
 	stderr := &bytes.Buffer{}
 	stdout := &bytes.Buffer{}
diff --git a/mage/testdata/args/magefile.go b/mage/testdata/args/magefile.go
index de0f262..b74483c 100644
--- a/mage/testdata/args/magefile.go
+++ b/mage/testdata/args/magefile.go
@@ -50,3 +50,7 @@ func Cough(ctx context.Context, b bool) error {
 func HasDep() {
 	mg.Deps(mg.F(Say, "hi", "Susan"))
 }
+
+func DoubleIt(f float64) {
+	fmt.Printf("%.1f * 2 = %.1f\n", f, f*2)
+}