nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: jcmturner/gokrb5
Pull request #163 (2018-07-09 12:49:20)

fix handling of varargs in Errorf()
Fixes https://github.com/jcmturner/gokrb5/issues/162

Re-use `Add()` function that does what we need; pass varargs as `a...`.

Also remove special-casing of empty varargs to aid readability.

jcmturner: Hi bboreham. Thanks for the contribution. There looks to be a compilation error with the test due to circular import...
```
# gopkg.in/jcmturner/gokrb5.v5/krberror
import cycle not allowed in test
package gopkg.in/jcmturner/gokrb5.v5/krberror (test)
	imports gopkg.in/jcmturner/gokrb5.v5/messages
	imports gopkg.in/jcmturner/gokrb5.v5/krberror
```
bboreham: Looks like I got distracted while writing that test.  It's better now.

Patch:
diff --git a/krberror/error.go b/krberror/error.go
index f2334d2..2e87bc2 100644
--- a/krberror/error.go
+++ b/krberror/error.go
@@ -45,17 +45,10 @@ func NewKrberror(et, s string) Krberror {
 // Errorf appends to or creates a new Krberror.
 func Errorf(err error, et, format string, a ...interface{}) Krberror {
 	if e, ok := err.(Krberror); ok {
-		if len(a) > 0 {
-			e.EText = append([]string{fmt.Sprintf("%s: "+format, et, a)}, e.EText...)
-			return e
-		}
-		e.EText = append([]string{fmt.Sprintf("%s: "+format, et)}, e.EText...)
+		e.Add(et, fmt.Sprintf(format, a...))
 		return e
 	}
-	if len(a) > 0 {
-		return NewErrorf(et, format+": %s", a, err)
-	}
-	return NewErrorf(et, format+": %s", err)
+	return NewErrorf(et, format+": %s", append(a, err)...)
 }
 
 // NewErrorf creates a new Krberror from a formatted string.


Test patch:
diff --git a/krberror/error_test.go b/krberror/error_test.go
new file mode 100644
index 0000000..4878c84
--- /dev/null
+++ b/krberror/error_test.go
@@ -0,0 +1,23 @@
+package krberror
+
+import (
+	"fmt"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestErrorf(t *testing.T) {
+	err := fmt.Errorf("an error")
+	var a Krberror
+	a = Errorf(err, "cause", "some text")
+	assert.Equal(t, "[Root cause: cause] cause: some text: an error", a.Error())
+	a = Errorf(err, "cause", "arg1=%d arg2=%s", 123, "arg")
+	assert.Equal(t, "[Root cause: cause] cause: arg1=123 arg2=arg: an error", a.Error())
+
+	err = NewErrorf("another error", "some text")
+	a = Errorf(err, "cause", "some text")
+	assert.Equal(t, "[Root cause: another error] cause: some text < another error: some text", a.Error())
+	a = Errorf(err, "cause", "arg1=%d arg2=%s", 123, "arg")
+	assert.Equal(t, "[Root cause: another error] cause: arg1=123 arg2=arg < another error: some text", a.Error())
+}
Repository: pingcap/dumpling
Pull request #56 (2020-04-17 02:13:30)

consistency: enhance auto resolve consistency
When use tidb without tikv, dumpling should not set snapshot consistency.

codecov-io: # [Codecov](https://codecov.io/gh/pingcap/dumpling/pull/56?src=pr&el=h1) Report
> Merging [#56](https://codecov.io/gh/pingcap/dumpling/pull/56?src=pr&el=desc) into [master](https://codecov.io/gh/pingcap/dumpling/commit/53a39be1b43ca188f445ee08d02460565cc9f9e7&el=desc) will **decrease** coverage by `0.04%`.
> The diff coverage is `53.33%`.


```diff
@@            Coverage Diff             @@
##           master      #56      +/-   ##
==========================================
- Coverage   58.00%   57.95%   -0.05%     
==========================================
  Files          16       16              
  Lines        1512     1527      +15     
==========================================
+ Hits          877      885       +8     
- Misses        566      570       +4     
- Partials       69       72       +3     
```


Patch:
diff --git a/v4/export/consistency.go b/v4/export/consistency.go
index 796b0fe..def1209 100644
--- a/v4/export/consistency.go
+++ b/v4/export/consistency.go
@@ -112,6 +112,13 @@ func (c *ConsistencySnapshot) Setup() error {
 		}
 		c.snapshot = str[snapshotFieldIndex]
 	}
+	hasTiKV, err := CheckTiDBWithTiKV(c.db)
+	if err != nil {
+		return err
+	}
+	if !hasTiKV {
+		return nil
+	}
 	return SetTiDBSnapshot(c.db, c.snapshot)
 }
 
diff --git a/v4/export/sql.go b/v4/export/sql.go
index 998f3da..a81d2f3 100644
--- a/v4/export/sql.go
+++ b/v4/export/sql.go
@@ -284,6 +284,18 @@ func SetTiDBSnapshot(db *sql.DB, snapshot string) error {
 	return withStack(err)
 }
 
+func CheckTiDBWithTiKV(db *sql.DB) (bool, error) {
+	var count int
+	handleOneRow := func(rows *sql.Rows) error {
+		return rows.Scan(&count)
+	}
+	err := simpleQuery(db, "SELECT COUNT(1) as c FROM MYSQL.TiDB WHERE VARIABLE_NAME='tikv_gc_safe_point'", handleOneRow)
+	if err != nil {
+		return false, err
+	}
+	return count > 0, nil
+}
+
 func buildSelectField(db *sql.DB, dbName, tableName string) (string, error) {
 	query := `SELECT COLUMN_NAME,EXTRA FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA=? AND TABLE_NAME=?;`
 	rows, err := db.Query(query, dbName, tableName)


Test patch:
diff --git a/v4/export/consistency_test.go b/v4/export/consistency_test.go
index 56eae8f..d5531ee 100644
--- a/v4/export/consistency_test.go
+++ b/v4/export/consistency_test.go
@@ -52,7 +52,11 @@ func (s *testConsistencySuite) TestConsistencyController(c *C) {
 	conf.Snapshot = "" // let dumpling detect the TSO
 	rows := sqlmock.NewRows([]string{"File", "Position", "Binlog_Do_DB", "Binlog_Ignore_DB", "Executed_Gtid_Set"})
 	rows.AddRow("tidb-binlog", "413802961528946688", "", "", "")
+	tidbRows := sqlmock.NewRows([]string{"c"})
+	tidbRows.AddRow(1)
 	mock.ExpectQuery("SHOW MASTER STATUS").WillReturnRows(rows)
+	mock.ExpectQuery("SELECT COUNT\\(1\\) as c FROM MYSQL.TiDB WHERE VARIABLE_NAME='tikv_gc_safe_point'").
+		WillReturnRows(tidbRows)
 	mock.ExpectExec("SET SESSION tidb_snapshot").
 		WillReturnResult(sqlmock.NewResult(0, 1))
 	ctrl, _ = NewConsistencyController(conf, db)