nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: kubernetes-sigs/kwok
Pull request #279 (2023-02-11 17:27:21)

Automated cherry pick of #275: Avoid clearing empty finalizers
Cherry pick of #275 on release-0.1.

#275: Avoid clearing empty finalizers

For details on the cherry pick process, see the [cherry pick requests](https://git.k8s.io/community/contributors/devel/sig-release/cherry-picks.md) page.

```release-note

```


Patch:
diff --git a/pkg/kwok/controllers/finalizers.go b/pkg/kwok/controllers/finalizers.go
index 79eb0e92..1841b932 100644
--- a/pkg/kwok/controllers/finalizers.go
+++ b/pkg/kwok/controllers/finalizers.go
@@ -100,7 +100,10 @@ func finalizersModify(metaFinalizers []string, finalizers *internalversion.Stage
 			ops = append(ops, finalizersAdd(metaFinalizers, finalizers.Add)...)
 		}
 	} else {
-		ops = append(ops, finalizersEmpty)
+		if len(metaFinalizers) != 0 {
+			ops = append(ops, finalizersEmpty)
+		}
+
 		if len(finalizers.Add) != 0 {
 			ops = append(ops, finalizersAdd(nil, finalizers.Add)...)
 		}


Test patch:
diff --git a/pkg/kwok/controllers/finalizers_test.go b/pkg/kwok/controllers/finalizers_test.go
index 2c2d3c7d..ad03c023 100644
--- a/pkg/kwok/controllers/finalizers_test.go
+++ b/pkg/kwok/controllers/finalizers_test.go
@@ -121,3 +121,76 @@ func Test_finalizersRemove(t *testing.T) {
 		})
 	}
 }
+
+func Test_finalizersModify(t *testing.T) {
+	type args struct {
+		metaFinalizers []string
+		finalizers     *internalversion.StageFinalizers
+	}
+	tests := []struct {
+		name string
+		args args
+		want []jsonpathOperation
+	}{
+		{
+			args: args{
+				metaFinalizers: nil,
+				finalizers: &internalversion.StageFinalizers{
+					Empty: true,
+				},
+			},
+			want: nil,
+		},
+		{
+			args: args{
+				metaFinalizers: []string{"a"},
+				finalizers: &internalversion.StageFinalizers{
+					Empty: true,
+				},
+			},
+			want: []jsonpathOperation{
+				{Op: "remove", Path: "/metadata/finalizers", Value: nil},
+			},
+		},
+		{
+			args: args{
+				metaFinalizers: []string{"a"},
+				finalizers: &internalversion.StageFinalizers{
+					Empty: true,
+					Add: []internalversion.FinalizerItem{
+						{
+							Value: "b",
+						},
+					},
+				},
+			},
+			want: []jsonpathOperation{
+				{Op: "remove", Path: "/metadata/finalizers", Value: nil},
+				{Op: "add", Path: "/metadata/finalizers", Value: []string{"b"}},
+			},
+		},
+		{
+			args: args{
+				metaFinalizers: nil,
+				finalizers: &internalversion.StageFinalizers{
+					Empty: true,
+					Add: []internalversion.FinalizerItem{
+						{
+							Value: "b",
+						},
+					},
+				},
+			},
+			want: []jsonpathOperation{
+				{Op: "add", Path: "/metadata/finalizers", Value: []string{"b"}},
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			if got := finalizersModify(tt.args.metaFinalizers, tt.args.finalizers); !reflect.DeepEqual(got, tt.want) {
+				t.Errorf("finalizersModify() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
Repository: rustwasm/wasm-pack
Pull request #197 (2018-07-04 09:16:27)

fix(mainfest): missing _bg.js file in package.json
Make sure these boxes are checked! 📦✅

- [ x] You have the latest version of `rustfmt` installed and have your 
      cloned directory set to nightly
```bash
$ rustup override set nightly
$ rustup component add rustfmt-preview --toolchain nightly
```
- [ x] You ran `rustfmt` on the code base before submitting
- [ ] You reference which issue is being closed in the PR text

✨✨ 😄 Thanks so much for contributing to wasm-pack! 😄 ✨✨



Patch:
diff --git a/src/manifest.rs b/src/manifest.rs
index 7addfb5..7dc2edd 100644
--- a/src/manifest.rs
+++ b/src/manifest.rs
@@ -71,6 +71,7 @@ impl CargoManifest {
     fn into_npm(mut self, scope: &Option<String>, disable_dts: bool) -> NpmPackage {
         let filename = self.package.name.replace("-", "_");
         let wasm_file = format!("{}_bg.wasm", filename);
+        let js_bg_file = format!("{}_bg.js", filename);
         let js_file = format!("{}.js", filename);
         let dts_file = if disable_dts == true {
             None
@@ -81,7 +82,7 @@ impl CargoManifest {
         if let Some(s) = scope {
             self.package.name = format!("@{}/{}", s, self.package.name);
         }
-        let mut files = vec![wasm_file];
+        let mut files = vec![wasm_file, js_bg_file];
 
         match dts_file {
             Some(ref dts_file) => {


Test patch:
diff --git a/tests/manifest/main.rs b/tests/manifest/main.rs
index 6f2b039..d117127 100644
--- a/tests/manifest/main.rs
+++ b/tests/manifest/main.rs
@@ -59,7 +59,10 @@ fn it_creates_a_package_json_default_path() {
         pkg.repository.url,
         "https://github.com/ashleygwilliams/wasm-pack.git"
     );
-    assert_eq!(pkg.files, ["wasm_pack_bg.wasm", "wasm_pack.d.ts"]);
+    assert_eq!(
+        pkg.files,
+        ["wasm_pack_bg.wasm", "wasm_pack_bg.js", "wasm_pack.d.ts"]
+    );
     assert_eq!(pkg.main, "wasm_pack.js");
     let types = pkg.types.unwrap_or_default();
     assert_eq!(types, "wasm_pack.d.ts");
Repository: rustwasm/wasm-pack
Pull request #204 (2018-07-13 15:33:42)

Revert "fix(mainfest): missing _bg.js file in package.json"
Reverts rustwasm/wasm-pack#197


Patch:
diff --git a/src/manifest.rs b/src/manifest.rs
index 7dc2edd..7addfb5 100644
--- a/src/manifest.rs
+++ b/src/manifest.rs
@@ -71,7 +71,6 @@ impl CargoManifest {
     fn into_npm(mut self, scope: &Option<String>, disable_dts: bool) -> NpmPackage {
         let filename = self.package.name.replace("-", "_");
         let wasm_file = format!("{}_bg.wasm", filename);
-        let js_bg_file = format!("{}_bg.js", filename);
         let js_file = format!("{}.js", filename);
         let dts_file = if disable_dts == true {
             None
@@ -82,7 +81,7 @@ impl CargoManifest {
         if let Some(s) = scope {
             self.package.name = format!("@{}/{}", s, self.package.name);
         }
-        let mut files = vec![wasm_file, js_bg_file];
+        let mut files = vec![wasm_file];
 
         match dts_file {
             Some(ref dts_file) => {


Test patch:
diff --git a/tests/manifest/main.rs b/tests/manifest/main.rs
index d117127..6f2b039 100644
--- a/tests/manifest/main.rs
+++ b/tests/manifest/main.rs
@@ -59,10 +59,7 @@ fn it_creates_a_package_json_default_path() {
         pkg.repository.url,
         "https://github.com/ashleygwilliams/wasm-pack.git"
     );
-    assert_eq!(
-        pkg.files,
-        ["wasm_pack_bg.wasm", "wasm_pack_bg.js", "wasm_pack.d.ts"]
-    );
+    assert_eq!(pkg.files, ["wasm_pack_bg.wasm", "wasm_pack.d.ts"]);
     assert_eq!(pkg.main, "wasm_pack.js");
     let types = pkg.types.unwrap_or_default();
     assert_eq!(types, "wasm_pack.d.ts");