nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: JanDeDobbeleer/oh-my-posh
Pull request #1684 (2022-02-04 08:09:29)

fix: migrate console title template
### Prerequisites

- [ ] I have read and understood the `CONTRIBUTING` guide
- [ ] The commit message follows the [conventional commits][cc] guidelines
- [ ] Tests for the changes have been added (for bug fixes/features)
- [ ] Docs have been added / updated (for bug fixes/features)

### Description

relates to #1678


<!---

Tips:

If you're not comfortable with working with Git, we're working a guide (https://ohmyposh.dev/docs/contributing_git) to help you out.
Oh My Posh advises GitKraken (https://www.gitkraken.com/invite/nQmDPR9D) as your preferred cross platform Git GUI power tool.

-->

[cc]: https://www.conventionalcommits.org/en/v1.0.0/#summary



Patch:
diff --git a/src/engine/migrate.go b/src/engine/migrate.go
index 2cc5411a..6c97ad32 100644
--- a/src/engine/migrate.go
+++ b/src/engine/migrate.go
@@ -24,6 +24,9 @@ func (cfg *Config) Migrate(env environment.Environment) {
 	for _, segment := range cfg.Tooltips {
 		segment.migrate(env, cfg.Version)
 	}
+	if strings.Contains(cfg.ConsoleTitleTemplate, ".Path") {
+		cfg.ConsoleTitleTemplate = strings.ReplaceAll(cfg.ConsoleTitleTemplate, ".Path", ".PWD")
+	}
 	cfg.updated = true
 	cfg.Version = configVersion
 }


Test patch:
diff --git a/src/engine/migrate_test.go b/src/engine/migrate_test.go
index 44d4a574..6d392f97 100644
--- a/src/engine/migrate_test.go
+++ b/src/engine/migrate_test.go
@@ -383,3 +383,22 @@ func TestMigratePreAndPostfix(t *testing.T) {
 		assert.NotContains(t, segment.Properties, "postfix", tc.Case)
 	}
 }
+
+func TestMigrateConfig(t *testing.T) {
+	cases := []struct {
+		Case     string
+		Expected string
+		Template string
+	}{
+		{Case: "Path", Expected: "{{ .PWD }}", Template: "{{ .Path }}"},
+		{Case: "No Path", Expected: "foo", Template: "foo"},
+		{Case: "Empty", Expected: "", Template: ""},
+	}
+	for _, tc := range cases {
+		cfg := &Config{
+			ConsoleTitleTemplate: tc.Template,
+		}
+		cfg.Migrate(&mock.MockedEnvironment{})
+		assert.Equal(t, tc.Expected, cfg.ConsoleTitleTemplate, tc.Case)
+	}
+}
Repository: JanDeDobbeleer/oh-my-posh
Pull request #1817 (2022-02-26 17:59:19)

fix(migrate): map .ComputerName to .HostName
### Prerequisites

- [x] I have read and understood the `CONTRIBUTING` guide
- [x] The commit message follows the [conventional commits][cc] guidelines
- [x] Tests for the changes have been added (for bug fixes/features)
- [x] Docs have been added / updated (for bug fixes/features)

### Description

relates to #1815


<!---

Tips:

If you're not comfortable with working with Git, we're working a guide (https://ohmyposh.dev/docs/contributing_git) to help you out.
Oh My Posh advises GitKraken (https://www.gitkraken.com/invite/nQmDPR9D) as your preferred cross platform Git GUI power tool.

-->

[cc]: https://www.conventionalcommits.org/en/v1.0.0/#summary



Patch:
diff --git a/src/engine/migrate.go b/src/engine/migrate.go
index 77071286..0f5b5b1f 100644
--- a/src/engine/migrate.go
+++ b/src/engine/migrate.go
@@ -106,6 +106,7 @@ func (segment *Segment) migrationOne(env environment.Environment) {
 		segment.migrateTemplate()
 		segment.migrateIconOverride("ssh_icon", "\uf817 ")
 		template := segment.Properties.GetString(properties.SegmentTemplate, segment.writer.Template())
+		template = strings.ReplaceAll(template, ".ComputerName", ".HostName")
 		if !segment.Properties.GetBool(properties.Property("display_host"), true) {
 			template = strings.ReplaceAll(template, "@{{ .HostName }}", "")
 		}


Test patch:
diff --git a/src/engine/migrate_test.go b/src/engine/migrate_test.go
index 283c8ba6..7ef353ab 100644
--- a/src/engine/migrate_test.go
+++ b/src/engine/migrate_test.go
@@ -310,6 +310,14 @@ func TestSegmentTemplateMigration(t *testing.T) {
 				"host_color": "#789012",
 			},
 		},
+		{
+			Case:     "SESSION - Existing template",
+			Expected: " {{ .UserName }}@{{ .HostName }} ",
+			Type:     SESSION,
+			Props: properties.Map{
+				"template": "{{ .UserName }}@{{ .ComputerName }}",
+			},
+		},
 	}
 	for _, tc := range cases {
 		segment := &Segment{
Repository: BurntSushi/toml
Pull request #301 (2021-06-21 05:48:53)

Disallow trailing newline in inline tables
Explicitly disallowed in spec.


Patch:
diff --git a/lex.go b/lex.go
index d01f2e5..688a17c 100644
--- a/lex.go
+++ b/lex.go
@@ -592,8 +592,7 @@ func lexInlineTableValue(lx *lexer) stateFn {
 // key/value pair and the next pair (or the end of the table):
 // it ignores whitespace and expects either a ',' or a '}'.
 func lexInlineTableValueEnd(lx *lexer) stateFn {
-	r := lx.next()
-	switch {
+	switch r := lx.next(); {
 	case isWhitespace(r):
 		return lexSkip(lx, lexInlineTableValueEnd)
 	case isNL(r):
@@ -603,13 +602,18 @@ func lexInlineTableValueEnd(lx *lexer) stateFn {
 		return lexCommentStart
 	case r == comma:
 		lx.ignore()
+		lx.skip(isWhitespace)
+		if lx.peek() == '}' {
+			return lx.errorf("trailing comma not allowed in inline tables")
+		}
 		return lexInlineTableValue
 	case r == inlineTableEnd:
 		return lexInlineTableEnd
+	default:
+		return lx.errorf(
+			"expected a comma or an inline table terminator %q, but got %s instead",
+			inlineTableEnd, runeOrEOF(r))
 	}
-	return lx.errorf(
-		"expected a comma or an inline table terminator %q, but got %s instead",
-		inlineTableEnd, runeOrEOF(r))
 }
 
 func runeOrEOF(r rune) string {


Test patch:
diff --git a/toml_test.go b/toml_test.go
index 3d6f699..14aeab7 100644
--- a/toml_test.go
+++ b/toml_test.go
@@ -57,7 +57,6 @@ func TestToml(t *testing.T) {
 				"valid/array-mix-string-table",
 				"valid/inline-table-nest",
 
-				"invalid/inline-table-trailing-comma",
 				"invalid/string-literal-multiline-quotes",
 				"invalid/string-multiline-escape-space",
 			},
Repository: BurntSushi/toml
Pull request #302 (2021-06-21 16:51:45)

Deal with invalid '\ ' escapes
These always got detected as newline escapes, even when they're invalid:

	"""
	asdas \    more text
	"""

Can't really find a good way to fix this in the lexer; so check for this
special case in the parser instead.


Patch:
diff --git a/lex.go b/lex.go
index 688a17c..ce1fae5 100644
--- a/lex.go
+++ b/lex.go
@@ -789,9 +789,9 @@ func lexStringEscape(lx *lexer) stateFn {
 		fallthrough
 	case '"':
 		fallthrough
-	// Inside """ .. """ strings you can use \ to escape newlines, and any
-	// amount of whitespace can be between the \ and \n.
 	case ' ', '\t':
+		// Inside """ .. """ strings you can use \ to escape newlines, and any
+		// amount of whitespace can be between the \ and \n.
 		fallthrough
 	case '\\':
 		return lx.pop()
diff --git a/parse.go b/parse.go
index aa7e9ab..34f1bf1 100644
--- a/parse.go
+++ b/parse.go
@@ -664,6 +664,9 @@ func (p *parser) replaceEscapes(str string) string {
 		default:
 			p.bug("Expected valid escape code after \\, but got %q.", s[r])
 			return ""
+		case ' ', '\t':
+			p.panicf("invalid escape: '\\%c'", s[r])
+			return ""
 		case 'b':
 			replaced = append(replaced, rune(0x0008))
 			r += 1


Test patch:
diff --git a/toml_test.go b/toml_test.go
index 14aeab7..17dff47 100644
--- a/toml_test.go
+++ b/toml_test.go
@@ -23,8 +23,9 @@ import (
 //
 // Filepaths are glob'd
 var errorTests = map[string][]string{
-	"encoding-bad-utf8*": {"invalid UTF-8 byte"},
-	"encoding-utf16*":    {"files cannot contain NULL bytes; probably using UTF-16"},
+	"encoding-bad-utf8*":            {"invalid UTF-8 byte"},
+	"encoding-utf16*":               {"files cannot contain NULL bytes; probably using UTF-16"},
+	"string-multiline-escape-space": {`invalid escape: '\ '`},
 }
 
 // Test metadata; all keys listed as "keyname: type".
@@ -58,7 +59,6 @@ func TestToml(t *testing.T) {
 				"valid/inline-table-nest",
 
 				"invalid/string-literal-multiline-quotes",
-				"invalid/string-multiline-escape-space",
 			},
 		}
Repository: BurntSushi/toml
Pull request #376 (2023-01-15 12:04:27)

Support times without seconds
In TOML 1.1 seconds are optional; e.g. `13:37` or `2001-02-03 13:37` are valid.

Like other TOML 1.1 features this is hidden behind a flag, and only supported for the tests.


Patch:
diff --git a/parse.go b/parse.go
index e5979af..2ee2297 100644
--- a/parse.go
+++ b/parse.go
@@ -333,11 +333,17 @@ func (p *parser) valueFloat(it item) (interface{}, tomlType) {
 var dtTypes = []struct {
 	fmt  string
 	zone *time.Location
+	next bool
 }{
-	{time.RFC3339Nano, time.Local},
-	{"2006-01-02T15:04:05.999999999", internal.LocalDatetime},
-	{"2006-01-02", internal.LocalDate},
-	{"15:04:05.999999999", internal.LocalTime},
+	{time.RFC3339Nano, time.Local, false},
+	{"2006-01-02T15:04:05.999999999", internal.LocalDatetime, false},
+	{"2006-01-02", internal.LocalDate, false},
+	{"15:04:05.999999999", internal.LocalTime, false},
+
+	// tomlNext
+	{"2006-01-02T15:04Z07:00", time.Local, true},
+	{"2006-01-02T15:04", internal.LocalDatetime, true},
+	{"15:04", internal.LocalTime, true},
 }
 
 func (p *parser) valueDatetime(it item) (interface{}, tomlType) {
@@ -348,6 +354,9 @@ func (p *parser) valueDatetime(it item) (interface{}, tomlType) {
 		err error
 	)
 	for _, dt := range dtTypes {
+		if dt.next && !tomlNext {
+			continue
+		}
 		t, err = time.ParseInLocation(dt.fmt, it.val, dt.zone)
 		if err == nil {
 			ok = true


Test patch:
diff --git a/internal/toml-test/version.go b/internal/toml-test/version.go
index 34985ed..50e0e2a 100644
--- a/internal/toml-test/version.go
+++ b/internal/toml-test/version.go
@@ -9,7 +9,11 @@ type versionSpec struct {
 }
 
 var versions = map[string]versionSpec{
-	"next": versionSpec{},
+	"next": versionSpec{
+		exclude: []string{
+			"invalid/datetime/no-secs", // Times without seconds is no longer invalid.
+		},
+	},
 
 	"1.0.0": versionSpec{
 		exclude: []string{
diff --git a/toml_test.go b/toml_test.go
index 05db96f..7664c4a 100644
--- a/toml_test.go
+++ b/toml_test.go
@@ -253,7 +253,9 @@ func TestTomlNext(t *testing.T) {
 
 // Make sure TOML 1.1 fails by default for now.
 func TestTomlNextFails(t *testing.T) {
-	runTomlTest(t, true, "valid/string/escape-esc")
+	runTomlTest(t, true,
+		"valid/string/escape-esc",
+		"valid/datetime/no-seconds")
 }
 
 func runTomlTest(t *testing.T, includeNext bool, wantFail ...string) {
@@ -317,9 +319,6 @@ func runTomlTest(t *testing.T, includeNext bool, wantFail ...string) {
 				"invalid/inline-table/add",
 				"invalid/table/duplicate-key-dotted-table",
 				"invalid/table/duplicate-key-dotted-table2",
-
-				// Upcoming TOML 1.1; not yet implemented
-				"valid/datetime/no-seconds",
 			},
 		}
 		if includeNext {
Repository: BurntSushi/toml
Pull request #381 (2023-01-28 14:35:34)

skip UTF-8 BOM also
I noticed that reading a UTF-8 encoded file with a BOM causes an error. Unfortunately, major Windows software adds a BOM to UTF-8 files.
UTF-16 support is fixed in #277 , but in addition, skipping the UTF-8 BOM (ef bb bf,  https://en.wikipedia.org/wiki/Byte_order_mark ) also solves the problem, I believe.

A sample is attached.

before:
```
OK(withoutBOM) あ
ERROR(withBOM) toml: line 1: expected '.' or '=', but got '\ufeff' instead
```

after:
```
OK(withoutBOM) あ
OK(withBOM) あ
```

[mini.zip](https://github.com/BurntSushi/toml/files/10527471/mini.zip)


Patch:
diff --git a/parse.go b/parse.go
index 9955966..535a164 100644
--- a/parse.go
+++ b/parse.go
@@ -47,9 +47,12 @@ func parse(data string) (p *parser, err error) {
 	}()
 
 	// Read over BOM; do this here as the lexer calls utf8.DecodeRuneInString()
-	// which mangles stuff.
-	if strings.HasPrefix(data, "\xff\xfe") || strings.HasPrefix(data, "\xfe\xff") {
+	// which mangles stuff. UTF-16 BOM isn't strictly valid, but some tools add
+	// it anyway.
+	if strings.HasPrefix(data, "\xff\xfe") || strings.HasPrefix(data, "\xfe\xff") { // UTF-16
 		data = data[2:]
+	} else if strings.HasPrefix(data, "\xef\xbb\xbf") { // UTF-8
+		data = data[3:]
 	}
 
 	// Examine first few bytes for NULL bytes; this probably means it's a UTF-16


Test patch:
diff --git a/decode_test.go b/decode_test.go
index 50a7081..99e5df8 100644
--- a/decode_test.go
+++ b/decode_test.go
@@ -66,6 +66,7 @@ func TestDecodeBOM(t *testing.T) {
 	for _, tt := range [][]byte{
 		[]byte("\xff\xfea = \"b\""),
 		[]byte("\xfe\xffa = \"b\""),
+		[]byte("\xef\xbb\xbfa = \"b\""),
 	} {
 		t.Run("", func(t *testing.T) {
 			var s struct{ A string }
Repository: BurntSushi/toml
Pull request #405 (2024-05-02 01:36:31)

Add Marshal Function
Added the Marshal function which returns the TOML representation of the Go value as bytes along with any error that may occur while marshaling. This adds parity with the existing Unmarshal function and conforms to the standard libraries JSON package, which also has both Unmarshal and Marshal.

arp242: Seems okay to add; can you add a basic test? Or maybe just modify one of the calls in `TestEncodeRoundTrip()`. Just to ensure the function is called and works – doesn't need to be comprehensive or anything.
samawise: Wrote a test for it under `TestEncodeRoundTrip()`.
arp242: Cheers, thanks

Patch:
diff --git a/encode.go b/encode.go
index 231ae63..73366c0 100644
--- a/encode.go
+++ b/encode.go
@@ -2,6 +2,7 @@ package toml
 
 import (
 	"bufio"
+	"bytes"
 	"encoding"
 	"encoding/json"
 	"errors"
@@ -76,6 +77,17 @@ type Marshaler interface {
 	MarshalTOML() ([]byte, error)
 }
 
+// Marshal returns a TOML representation of the Go value.
+//
+// See [Encoder] for a description of the encoding process.
+func Marshal(v any) ([]byte, error) {
+	buff := new(bytes.Buffer)
+	if err := NewEncoder(buff).Encode(v); err != nil {
+		return nil, err
+	}
+	return buff.Bytes(), nil
+}
+
 // Encoder encodes a Go to a TOML document.
 //
 // The mapping between Go values and TOML values should be precisely the same as


Test patch:
diff --git a/encode_test.go b/encode_test.go
index 4605e2c..fbf17de 100644
--- a/encode_test.go
+++ b/encode_test.go
@@ -53,6 +53,13 @@ func TestEncodeRoundTrip(t *testing.T) {
 	if firstBuffer.String() != secondBuffer.String() {
 		t.Errorf("%s\n\nIS NOT IDENTICAL TO\n\n%s", firstBuffer.String(), secondBuffer.String())
 	}
+	out, err := Marshal(inputs)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if firstBuffer.String() != string(out) {
+		t.Errorf("%s\n\nIS NOT IDENTICAL TO\n\n%s", firstBuffer.String(), string(out))
+	}
 }
 
 func TestEncodeArrayHashWithNormalHashOrder(t *testing.T) {
Repository: BurntSushi/toml
Pull request #440 (2025-04-01 13:27:00)

decode: mark nested fields as decoded as well
This commit is a small followup for PR#426 to handle another case with the custom unmarshal. This was found in a complex TOML based image customization "blueprint", c.f. https://github.com/osbuild/blueprint/pull/12

With this commit the test in the other PR passes but I also extracted a minimal testcase (the naming may need tweaking, I'm not super familar with the naming convention inside "toml")


Patch:
diff --git a/decode.go b/decode.go
index 3fa516c..639665d 100644
--- a/decode.go
+++ b/decode.go
@@ -206,6 +206,13 @@ func markDecodedRecursive(md *MetaData, tmap map[string]any) {
 			markDecodedRecursive(md, tmap)
 			md.context = md.context[0 : len(md.context)-1]
 		}
+		if tarr, ok := tmap[key].([]map[string]any); ok {
+			for _, elm := range tarr {
+				md.context = append(md.context, key)
+				markDecodedRecursive(md, elm)
+				md.context = md.context[0 : len(md.context)-1]
+			}
+		}
 	}
 }
 


Test patch:
diff --git a/decode_test.go b/decode_test.go
index 3e77e1d..e0cbd81 100644
--- a/decode_test.go
+++ b/decode_test.go
@@ -1157,11 +1157,12 @@ func (cs *UnmarshalTOMLNoop) UnmarshalTOML(data any) error {
 
 func TestDecodeCustomStructMarkedDecoded(t *testing.T) {
 	var s struct {
-		Str UnmarshalTOMLNoop `toml:"str"`
-		Int UnmarshalTOMLNoop `toml:"int"`
-		Arr UnmarshalTOMLNoop `toml:"arr"`
-		Tbl UnmarshalTOMLNoop `toml:"tbl"`
-		Aot UnmarshalTOMLNoop `toml:"aot"`
+		Str    UnmarshalTOMLNoop `toml:"str"`
+		Int    UnmarshalTOMLNoop `toml:"int"`
+		Arr    UnmarshalTOMLNoop `toml:"arr"`
+		Tbl    UnmarshalTOMLNoop `toml:"tbl"`
+		Aot    UnmarshalTOMLNoop `toml:"aot"`
+		Nested UnmarshalTOMLNoop `toml:"nested"`
 	}
 	meta, err := Decode(`
 		str = "bar"
@@ -1176,6 +1177,11 @@ func TestDecodeCustomStructMarkedDecoded(t *testing.T) {
 		a = 1
 		[[aot]]
 		a = 1
+
+		[[nested.a]]
+		e = 5
+		[[nested.a]]
+		f = 6
 	`, &s)
 	if err != nil {
 		t.Fatalf("Decode failed: %s", err)
Repository: wix/Detox
Pull request #3435 (2022-05-31 15:23:32)

fix: more reliable uninstall for multiple apps
## Description

When the applications from the same publisher can share the stored credentials with each other, it turns out that in order to delete the credentials from the simulator you have to uninstall ALL the applications before you start installing them back again.

That's why I have to change subtly the strategy of reinstall here.


Patch:
diff --git a/detox/src/Detox.js b/detox/src/Detox.js
index 7d0c0624f..0ec8832cf 100644
--- a/detox/src/Detox.js
+++ b/detox/src/Detox.js
@@ -251,6 +251,10 @@ class Detox {
     for (const appName of appNames) {
       await this.device.selectApp(appName);
       await this.device.uninstallApp();
+    }
+
+    for (const appName of appNames) {
+      await this.device.selectApp(appName);
       await this.device.installApp();
     }
 


Test patch:
diff --git a/detox/src/Detox.test.js b/detox/src/Detox.test.js
index 5ffdea1d7..a3fb2dff4 100644
--- a/detox/src/Detox.test.js
+++ b/detox/src/Detox.test.js
@@ -244,10 +244,12 @@ describe('Detox', () => {
         expect(runtimeDevice.uninstallApp).toHaveBeenCalledTimes(2);
         expect(runtimeDevice.installApp).toHaveBeenCalledTimes(2);
 
-        expect(runtimeDevice.selectApp).toHaveBeenCalledTimes(3);
+        expect(runtimeDevice.selectApp).toHaveBeenCalledTimes(5);
         expect(runtimeDevice.selectApp.mock.calls[0]).toEqual(['default']);
         expect(runtimeDevice.selectApp.mock.calls[1]).toEqual(['extraApp']);
-        expect(runtimeDevice.selectApp.mock.calls[2]).toEqual([null]);
+        expect(runtimeDevice.selectApp.mock.calls[2]).toEqual(['default']);
+        expect(runtimeDevice.selectApp.mock.calls[3]).toEqual(['extraApp']);
+        expect(runtimeDevice.selectApp.mock.calls[4]).toEqual([null]);
       });
     });
Repository: wix/Detox
Pull request #3594 (2022-09-15 07:36:09)

Update NetworkFormatter.js
In logs network address we have this: 
```
• 1 network requests with URLs:
  - URL #1: https://google.com/api.
```

And this `.` at the end is very confusing when try to click on this link.
Suggest to remove this `.`

mikasius: There are a snapshot errors.
Snapshots need to be updated.

Patch:
diff --git a/detox/src/client/actions/formatters/sync-resources/NetworkFormatter.js b/detox/src/client/actions/formatters/sync-resources/NetworkFormatter.js
index 6d8b03aae..7fdf2b2bc 100644
--- a/detox/src/client/actions/formatters/sync-resources/NetworkFormatter.js
+++ b/detox/src/client/actions/formatters/sync-resources/NetworkFormatter.js
@@ -1,7 +1,7 @@
 const { makeResourceTitle, makeResourceSubTitle } = require('./utils');
 
 function makeURLDescription(url, urlCount) {
-  return makeResourceSubTitle(`URL #${urlCount}: ${url}.`);
+  return makeResourceSubTitle(`URL #${urlCount}: ${url}`);
 }
 
 module.exports = function(properties) {


Test patch:
diff --git a/detox/src/client/actions/formatters/__snapshots__/SyncStatusFormatter.test.js.snap b/detox/src/client/actions/formatters/__snapshots__/SyncStatusFormatter.test.js.snap
index cad4d25e6..3b1e7492a 100644
--- a/detox/src/client/actions/formatters/__snapshots__/SyncStatusFormatter.test.js.snap
+++ b/detox/src/client/actions/formatters/__snapshots__/SyncStatusFormatter.test.js.snap
@@ -136,8 +136,8 @@ exports[`Sync Status Formatter busy status should format "looper" correctly 1`]
 exports[`Sync Status Formatter busy status should format "network" correctly 1`] = `
 "The app is busy with the following tasks:
 • 2 network requests with URLs:
-  - URL #1: foo://bar.baz.
-  - URL #2: qux://quux.quuz."
+  - URL #1: foo://bar.baz
+  - URL #2: qux://quux.quuz"
 `;
 
 exports[`Sync Status Formatter busy status should format "one_time_events" correctly 1`] = `