nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: compose-spec/compose-go
Pull request #793 (2025-06-04 07:26:46)

fix ability to override values set in env file by interpolation
as we process env file, need to resolve interpolation variables from the env bine processed, which includes both env parsed from earlier file + variables read from previous lines in file. Still, values set by os.Env have higher precedence

closes https://github.com/docker/compose/issues/12901


Patch:
diff --git a/dotenv/env.go b/dotenv/env.go
index b01f993..fe8ce85 100644
--- a/dotenv/env.go
+++ b/dotenv/env.go
@@ -56,7 +56,7 @@ func GetEnvFromFile(currentEnv map[string]string, filenames []string) (map[strin
 			return envMap, err
 		}
 
-		env, err := ParseWithLookup(bytes.NewReader(b), func(k string) (string, bool) {
+		err = parseWithLookup(bytes.NewReader(b), envMap, func(k string) (string, bool) {
 			v, ok := currentEnv[k]
 			if ok {
 				return v, true
@@ -67,9 +67,6 @@ func GetEnvFromFile(currentEnv map[string]string, filenames []string) (map[strin
 		if err != nil {
 			return envMap, fmt.Errorf("failed to read %s: %w", dotEnvFile, err)
 		}
-		for k, v := range env {
-			envMap[k] = v
-		}
 	}
 
 	return envMap, nil


Test patch:
diff --git a/dotenv/godotenv_test.go b/dotenv/godotenv_test.go
index 17d6ae6..944bf40 100644
--- a/dotenv/godotenv_test.go
+++ b/dotenv/godotenv_test.go
@@ -741,3 +741,34 @@ func TestLoadWithFormat(t *testing.T) {
 	assert.NilError(t, err)
 	assert.DeepEqual(t, expectedValues, env)
 }
+
+func TestMultipleFiles(t *testing.T) {
+	base := filepath.Join(t.TempDir(), "base.env")
+	err := os.WriteFile(base, []byte(`
+ENV_HOSTNAME=localhost
+ENV_MY_URL="http://${ENV_HOSTNAME}"
+`), 0o600)
+	assert.NilError(t, err)
+
+	override := filepath.Join(t.TempDir(), "override.env")
+	err = os.WriteFile(override, []byte(`
+ENV_HOSTNAME=dev.my-company.com
+ENV_MY_URL="http://${ENV_HOSTNAME}"
+`), 0o600)
+	assert.NilError(t, err)
+
+	env, err := GetEnvFromFile(nil, []string{base, override})
+	assert.NilError(t, err)
+	assert.DeepEqual(t, env, map[string]string{
+		"ENV_HOSTNAME": "dev.my-company.com",
+		"ENV_MY_URL":   "http://dev.my-company.com",
+	})
+
+	osEnv := map[string]string{"ENV_HOSTNAME": "host.local"}
+	env, err = GetEnvFromFile(osEnv, []string{base, override})
+	assert.NilError(t, err)
+	assert.DeepEqual(t, env, map[string]string{
+		"ENV_HOSTNAME": "dev.my-company.com",
+		"ENV_MY_URL":   "http://host.local",
+	})
+}
Repository: compose-spec/compose-go
Pull request #802 (2025-06-30 18:38:02)

introduce mode_var for model binding


Patch:
diff --git a/schema/compose-spec.json b/schema/compose-spec.json
index 9aeb151..4c2af24 100644
--- a/schema/compose-spec.json
+++ b/schema/compose-spec.json
@@ -533,6 +533,10 @@
                     "endpoint_var": {
                       "type": "string",
                       "description": "Environment variable set to AI model endpoint."
+                    },
+                    "model_var": {
+                      "type": "string",
+                      "description": "Environment variable set to AI model name."
                     }
                   },
                   "additionalProperties": false,
diff --git a/types/derived.gen.go b/types/derived.gen.go
index 199792a..93adf49 100644
--- a/types/derived.gen.go
+++ b/types/derived.gen.go
@@ -1905,6 +1905,7 @@ func deriveDeepCopy_42(dst, src *DeviceRequest) {
 // deriveDeepCopy_43 recursively copies the contents of src into dst.
 func deriveDeepCopy_43(dst, src *ServiceModelConfig) {
 	dst.EndpointVariable = src.EndpointVariable
+	dst.ModelVariable = src.ModelVariable
 	if src.Extensions != nil {
 		dst.Extensions = make(map[string]any, len(src.Extensions))
 		src.Extensions.DeepCopy(dst.Extensions)
diff --git a/types/models.go b/types/models.go
index 8ddc7f8..4f144c0 100644
--- a/types/models.go
+++ b/types/models.go
@@ -26,5 +26,6 @@ type ModelConfig struct {
 
 type ServiceModelConfig struct {
 	EndpointVariable string     `yaml:"endpoint_var,omitempty" json:"endpoint_var,omitempty"`
+	ModelVariable    string     `yaml:"model_var,omitempty" json:"model_var,omitempty"`
 	Extensions       Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
 }


Test patch:
diff --git a/loader/loader_test.go b/loader/loader_test.go
index 5805136..1769084 100644
--- a/loader/loader_test.go
+++ b/loader/loader_test.go
@@ -3875,6 +3875,7 @@ services:
     models:
       foo:
         endpoint_var: MODEL_URL
+        model_var: MODEL
 
 models:
   foo:
@@ -3895,6 +3896,7 @@ models:
 	assert.DeepEqual(t, p.Services["test_mapping"].Models, map[string]*types.ServiceModelConfig{
 		"foo": {
 			EndpointVariable: "MODEL_URL",
+			ModelVariable:    "MODEL",
 		},
 	})
 }
Repository: compose-spec/compose-go
Pull request #811 (2025-07-21 18:58:59)

fix extraction of variables
This fixes the problem of extracting variables from a list of maps. Currently, variables from such an entity would be ignored. A simple way of reproduce this is to execute the following command:

```shell
docker compose -f docker-compose.volumes.yml config --variables
```

The content of `docker-compose.volumes.yml` is:
```yaml
services:
    postgres:
        environment:
            POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
            POSTGRES_USER: postgres
        image: postgres
        volumes:
            - ${CERT_FILE}:/certs/server.crt:ro
```

The output will be:
```shell
NAME                REQUIRED            DEFAULT VALUE       ALTERNATE VALUE
POSTGRES_PASSWORD   false               postgres            
```

`CERT_FILE` is missing. Internally, the volumes will be represented as `volumes:[map[read_only:true source:${CERT_FILE} target:/certs/server.crt type:volume volume:map[]]] `.


Patch:
diff --git a/template/variables.go b/template/variables.go
index 84edee5..376137b 100644
--- a/template/variables.go
+++ b/template/variables.go
@@ -57,10 +57,9 @@ func recurseExtract(value interface{}, pattern *regexp.Regexp) map[string]Variab
 
 	case []interface{}:
 		for _, elem := range value {
-			if values, is := extractVariable(elem, pattern); is {
-				for _, v := range values {
-					m[v.Name] = v
-				}
+			submap := recurseExtract(elem, pattern)
+			for key, value := range submap {
+				m[key] = value
 			}
 		}
 	}


Test patch:
diff --git a/template/variables_test.go b/template/variables_test.go
index b2b18f6..e0519ec 100644
--- a/template/variables_test.go
+++ b/template/variables_test.go
@@ -191,6 +191,22 @@ func TestExtractVariables(t *testing.T) {
 				"SUBDOMAIN":  {Name: "SUBDOMAIN", DefaultValue: "$ROOTDOMAIN"},
 			},
 		},
+		{
+			name: "nested-array-of-maps",
+			dict: map[string]interface{}{
+				"volumes": []interface{}{
+					map[string]interface{}{
+						"source": "${SOURCE_LOCATION}",
+						"target": "/location",
+						"type":   "volume",
+						"volume": map[string]interface{}{},
+					},
+				},
+			},
+			expected: map[string]Variable{
+				"SOURCE_LOCATION": {Name: "SOURCE_LOCATION"},
+			},
+		},
 	}
 	for _, tc := range testCases {
 		t.Run(tc.name, func(t *testing.T) {
Repository: wangguanquan/eec
Pull request #28 (2019-06-05 08:28:50)

Fix#26


Patch:
diff --git a/src/main/java/cn/ttzero/excel/reader/HeaderRow.java b/src/main/java/cn/ttzero/excel/reader/HeaderRow.java
index 3ffc2597..272c9754 100644
--- a/src/main/java/cn/ttzero/excel/reader/HeaderRow.java
+++ b/src/main/java/cn/ttzero/excel/reader/HeaderRow.java
@@ -43,6 +43,19 @@ class HeaderRow extends Row {
         for (int i = row.fc; i < row.lc; i++) {
             hr.names[i] = row.getString(i);
         }
+        // Extends from row
+        hr.fc = row.fc;
+        hr.lc = row.lc;
+        hr.index = row.index;
+        hr.cells = new Cell[hr.names.length];
+        for (int i = 0; i < row.fc; i++) {
+            hr.cells[i] = new Cell();
+        }
+        for (int i = row.fc; i < row.lc; i++) {
+            Cell cell = new Cell();
+            cell.setSv(hr.names[i]);
+            hr.cells[i] = cell;
+        }
         return hr;
     }
 


Test patch:
diff --git a/src/test/java/cn/ttzero/excel/reader/ExcelReaderTest.java b/src/test/java/cn/ttzero/excel/reader/ExcelReaderTest.java
index 797eb067..ad114f15 100644
--- a/src/test/java/cn/ttzero/excel/reader/ExcelReaderTest.java
+++ b/src/test/java/cn/ttzero/excel/reader/ExcelReaderTest.java
@@ -28,6 +28,7 @@ import java.nio.file.Paths;
 import java.util.Iterator;
 
 import static cn.ttzero.excel.Print.println;
+import static cn.ttzero.excel.Print.print;
 
 /**
  * Create by guanquan.wang at 2019-04-26 17:42
@@ -89,4 +90,28 @@ public class ExcelReaderTest {
             e.printStackTrace();
         }
     }
+
+    @Test public void testForEach() {
+        try (ExcelReader reader = ExcelReader.read(testResourceRoot().resolve("1.xlsx"))) {
+            Sheet sheet = reader.sheet(0);
+
+            Row header = sheet.getHeader();
+
+            for (Iterator<Row> it = sheet.iterator(); it.hasNext(); ) {
+                Row row = it.next();
+                if (row.getRowNumber() == 0) continue;
+
+                print(row.getRowNumber());
+                for (int start = 0, end = row.getLastColumnIndex(); start < end; start++) {
+                    print(header.getString(start));
+                    print(" : ");
+                    print(row.getString(start));
+                    print(' ');
+                }
+                println();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
 }
Repository: wangguanquan/eec
Pull request #37 (2019-06-19 07:21:51)

Fix#35


Patch:
diff --git a/src/main/java/cn/ttzero/excel/entity/style/Styles.java b/src/main/java/cn/ttzero/excel/entity/style/Styles.java
index 63e2634c..b8b5a99f 100644
--- a/src/main/java/cn/ttzero/excel/entity/style/Styles.java
+++ b/src/main/java/cn/ttzero/excel/entity/style/Styles.java
@@ -200,6 +200,10 @@ public class Styles implements Storageable {
         Element root = document.getRootElement();
         // Number format
         Element numFmts = root.element("numFmts");
+        // Break if there don't contains 'numFmts' tag
+        if (numFmts == null) {
+            return self;
+        }
         List<Element> sub = numFmts.elements();
         self.numFmts = new ArrayList<>();
         for (Element e : sub) {
diff --git a/src/main/java/cn/ttzero/excel/reader/SharedStrings.java b/src/main/java/cn/ttzero/excel/reader/SharedStrings.java
index 53f5c271..8f9f77b0 100644
--- a/src/main/java/cn/ttzero/excel/reader/SharedStrings.java
+++ b/src/main/java/cn/ttzero/excel/reader/SharedStrings.java
@@ -208,7 +208,7 @@ public class SharedStrings implements AutoCloseable {
     private int uniqueCount() throws IOException {
         int off = -1;
         reader = Files.newBufferedReader(sstPath);
-        cb = new char[2048];
+        cb = new char[1 << 12];
         offset = 0;
         offset = reader.read(cb);
 
@@ -359,7 +359,7 @@ public class SharedStrings implements AutoCloseable {
      * Read data from main reader
      * forward only
      *
-     * @return word count
+     * @return the word count
      * @throws IOException if I/O error occur
      */
     private int readData() throws IOException {


Test patch:
diff --git a/src/test/java/cn/ttzero/excel/reader/ExcelReaderTest.java b/src/test/java/cn/ttzero/excel/reader/ExcelReaderTest.java
index ad114f15..bbdf8efb 100644
--- a/src/test/java/cn/ttzero/excel/reader/ExcelReaderTest.java
+++ b/src/test/java/cn/ttzero/excel/reader/ExcelReaderTest.java
@@ -105,7 +105,14 @@ public class ExcelReaderTest {
                 for (int start = 0, end = row.getLastColumnIndex(); start < end; start++) {
                     print(header.getString(start));
                     print(" : ");
-                    print(row.getString(start));
+                    CellType type = row.getCellType(start);
+                    switch (type) {
+                        case DATE    : print(row.getTimestamp(start)); break;
+                        case INTEGER : print(row.getInt(start))      ; break;
+                        case LONG    : print(row.getLong(start))     ; break;
+                        case DOUBLE  : print(row.getDouble(start))   ; break;
+                        default      : print(row.getString(start))   ; break;
+                    }
                     print(' ');
                 }
                 println();
Repository: wangguanquan/eec
Pull request #64 (2019-07-10 14:43:44)

Fix#63 NPE occur if put a removed key
fix NPE


Patch:
diff --git a/src/main/java/org/ttzero/excel/reader/FixSizeLRUCache.java b/src/main/java/org/ttzero/excel/reader/FixSizeLRUCache.java
index d7dfc7f6..4e5fcdb3 100644
--- a/src/main/java/org/ttzero/excel/reader/FixSizeLRUCache.java
+++ b/src/main/java/org/ttzero/excel/reader/FixSizeLRUCache.java
@@ -172,6 +172,9 @@ public class FixSizeLRUCache<K, V> implements Cache<K, V> {
         // Not found
         if (size == 0 || (o = table.get(k)) == null) return null;
 
+        // Remove the keyword from the hash table to make them unsearchable
+        table.remove(k);
+
         final Node<E<K, V>> prev = o.prev, next = o.next;
 
         if (prev == null) {


Test patch:
diff --git a/src/test/java/org/ttzero/excel/reader/CacheTest.java b/src/test/java/org/ttzero/excel/reader/CacheTest.java
index e4b2c357..37fbf719 100644
--- a/src/test/java/org/ttzero/excel/reader/CacheTest.java
+++ b/src/test/java/org/ttzero/excel/reader/CacheTest.java
@@ -110,4 +110,15 @@ public class CacheTest {
         assert hot.size() == 0;
         hot.forEach(e -> println(e.getKey() + ": " + e.getValue()));
     }
+
+    @Test public void testRemoveAndAdd() {
+        Cache<String, Integer> cache = FixSizeLRUCache.create();
+        cache.put("a", 1);
+        cache.put("b", 2);
+
+        cache.remove("a");
+        cache.put("a", 5);
+
+        cache.forEach(e -> println(e.getKey() + ": " + e.getValue()));
+    }
 }
Repository: submariner-io/lighthouse
Pull request #452 (2021-02-04 07:04:35)

Add Multiple ports to ServiceImport
If service has multiple ports, add them all to ServiceImport,
not just first one.

Signed-off-by: Vishal Thapar <5137689+vthapar@users.noreply.github.com>

tpantelis: > Any chance this could have an associated unit test?

yeah https://github.com/submariner-io/lighthouse/pull/451 adds test for service ports. We should merge that first and add another test case here.
tpantelis: > > Any chance this could have an associated unit test?
> 
> yeah #451 adds test for service ports. We should merge that first and add another test case here.

@vthapar since #451 was merged, can you change the service port test case to have 2 ports to cover these changes?
vthapar: > Any chance this could have an associated unit test?

Done

Patch:
diff --git a/pkg/agent/controller/agent.go b/pkg/agent/controller/agent.go
index 3000965..a324166 100644
--- a/pkg/agent/controller/agent.go
+++ b/pkg/agent/controller/agent.go
@@ -427,14 +427,12 @@ func (a *Controller) getIPsAndPortsForService(service *corev1.Service, siType mc
 	[]string, []mcsv1a1.ServicePort, error) {
 	var mcsPorts []mcsv1a1.ServicePort
 
-	if len(service.Spec.Ports) > 0 {
-		mcsPorts = []mcsv1a1.ServicePort{
-			{
-				Name:     service.Spec.Ports[0].Name,
-				Protocol: service.Spec.Ports[0].Protocol,
-				Port:     service.Spec.Ports[0].Port,
-			},
-		}
+	for _, port := range service.Spec.Ports {
+		mcsPorts = append(mcsPorts, mcsv1a1.ServicePort{
+			Name:     port.Name,
+			Protocol: port.Protocol,
+			Port:     port.Port,
+		})
 	}
 
 	if siType == mcsv1a1.ClusterSetIP {


Test patch:
diff --git a/pkg/agent/controller/agent_test.go b/pkg/agent/controller/agent_test.go
index 771795f..f26d36b 100644
--- a/pkg/agent/controller/agent_test.go
+++ b/pkg/agent/controller/agent_test.go
@@ -182,6 +182,11 @@ var _ = Describe("ServiceImport syncing", func() {
 					Protocol: corev1.ProtocolTCP,
 					Port:     123,
 				},
+				{
+					Name:     "eth1",
+					Protocol: corev1.ProtocolTCP,
+					Port:     1234,
+				},
 			}
 		})