nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: svg/svgo
Pull request #427 (2015-09-08 14:46:53)

New plugin: Remove style elements - disable by default.
I'm going ahead with recreating. Hopefully this is the right place.


Patch:
diff --git a/.svgo.yml b/.svgo.yml
index 697aefb..e784478 100644
--- a/.svgo.yml
+++ b/.svgo.yml
@@ -51,3 +51,4 @@ plugins:
   - removeDimensions
   - removeAttrs
   - addClassesToSVGElement
+  - removeStyleElement
diff --git a/plugins/removeStyleElement.js b/plugins/removeStyleElement.js
new file mode 100644
index 0000000..90e0d39
--- /dev/null
+++ b/plugins/removeStyleElement.js
@@ -0,0 +1,23 @@
+'use strict';
+
+exports.type = 'perItem';
+
+exports.active = false;
+
+exports.description = 'removes <style>';
+
+/**
+ * Remove <style>.
+ *
+ * http://www.w3.org/TR/SVG/styling.html#StyleElement
+ *
+ * @param {Object} item current iteration item
+ * @return {Boolean} if false, item will be filtered out
+ *
+ * @author Betsy Dupuis
+ */
+exports.fn = function(item) {
+
+    return !item.isElem('style');
+
+};


Test patch:
diff --git a/test/plugins/removeStyleElement.01.svg b/test/plugins/removeStyleElement.01.svg
new file mode 100644
index 0000000..2f3c52f
--- /dev/null
+++ b/test/plugins/removeStyleElement.01.svg
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-16"?>
+    <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">
+        <style type="text/css">
+        .st0 {
+            fill: #231F20;
+        }
+        </style>
+        <circle class="st0" cx="50" cy="50" r="50" />
+    </svg>
+
+@@@
+
+<?xml version="1.0" encoding="utf-16"?>
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">
+    <circle class="st0" cx="50" cy="50" r="50"/>
+</svg>
\ No newline at end of file
Repository: svg/svgo
Pull request #435 (2015-10-06 07:24:43)

fix TypeError("Can't get property contents of undefined") 
Plugin removeUnknownsAndDefaults.

If an element is encountered that doesn't exist in collections.elems, unhandled exception occurs as there is no existence check.

Encountered with this xml block (Illustrator export)
```
<metadata>
	<sfw  xmlns="&ns_sfw;">
		<slices></slices>
		<sliceSourceBounds  height="67.3" width="85.9" y="-40.8" x="-42.5" bottomLeftOrigin="true"></sliceSourceBounds>
	</sfw>
</metadata>
```


Patch:
diff --git a/plugins/removeUnknownsAndDefaults.js b/plugins/removeUnknownsAndDefaults.js
index 2e5f62c..c7130c8 100644
--- a/plugins/removeUnknownsAndDefaults.js
+++ b/plugins/removeUnknownsAndDefaults.js
@@ -74,13 +74,23 @@ exports.fn = function(item, params) {
         if (
             params.unknownContent &&
             !item.isEmpty() &&
-            elems[elem].content
+            elems[elem] && //make sure we know of this element before checking its children
+            elem !== 'foreignObject'//Don't check foreignObject
         ) {
             item.content.forEach(function(content, i) {
                 if (
                     content.isElem() &&
-                    !content.prefix &&
-                    elems[elem].content.indexOf(content.elem) === -1
+                    !content.prefix && 
+                    (
+                        (
+                            elems[elem].content && // Do we have a record of its permitted content?
+                            elems[elem].content.indexOf(content.elem) === -1
+                        ) || 
+                        (
+                            !elems[elem].content && // we dont know about its permitted content
+                            !elems[content.elem] // check that we know about the element at all
+                        )
+                    )
                 ) {
                     item.content.splice(i, 1);
                 }
@@ -88,7 +98,7 @@ exports.fn = function(item, params) {
         }
 
         // remove element's unknown attrs and attrs with default values
-        if (elems[elem].attrs) {
+        if (elems[elem] && elems[elem].attrs) {
 
             item.eachAttr(function(attr) {
 


Test patch:
diff --git a/test/plugins/removeUnknownsAndDefaults.09.svg b/test/plugins/removeUnknownsAndDefaults.09.svg
new file mode 100644
index 0000000..a7cdb28
--- /dev/null
+++ b/test/plugins/removeUnknownsAndDefaults.09.svg
@@ -0,0 +1,21 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+    <metadata>
+        <sfw>
+            <slices></slices>
+            <sliceSourceBounds height="67.3" width="85.9" y="-40.8" x="-42.5" bottomLeftOrigin="true"></sliceSourceBounds>
+        </sfw>
+        <ellipse/>
+    </metadata>
+    <ellipse>
+        <font-face/>
+    </ellipse>
+</svg>
+
+@@@
+
+<svg xmlns="http://www.w3.org/2000/svg">
+    <metadata>
+        <ellipse/>
+    </metadata>
+    <ellipse/>
+</svg>
Repository: svg/svgo
Pull request #521 (2016-03-21 17:19:02)

Add currentColor param to convertColors plugin
This is related to #497, but instead of creating a new plugin it adds an additional param to the existing `convertColors` plugin. 

Part of the issue that this addresses, if a color is defined within an SVG you can't override the color easily in CSS without manually editing the SVG. With this new param, you can automatically convert colors to `currentColor` allowing CSS overrides.

The only downside of it being a param within `convertColors`, is that it will override any other params when set to true. That's why initially `currentColor` defaults to `false`.

The only other potential change I could see is to take into account `transparent` values. I'm not sure if transparent values should or should not be converted. For my use case, if a color value is transparent we don't need it changed, but I could see it being different for someone else.


Patch:
diff --git a/plugins/convertColors.js b/plugins/convertColors.js
index 32541c6..8a91b8d 100644
--- a/plugins/convertColors.js
+++ b/plugins/convertColors.js
@@ -7,6 +7,7 @@ exports.active = true;
 exports.description = 'converts colors: rgb() to #rrggbb and #rrggbb to #rgb';
 
 exports.params = {
+    currentColor: false,
     names2hex: true,
     rgb2hex: true,
     shorthex: true,
@@ -17,7 +18,8 @@ var collections = require('./_collections'),
     rNumber = '([+-]?(?:\\d*\\.\\d+|\\d+\\.?)%?)',
     rComma = '\\s*,\\s*',
     regRGB = new RegExp('^rgb\\(\\s*' + rNumber + rComma + rNumber + rComma + rNumber + '\\s*\\)$'),
-    regHEX = /^\#(([a-fA-F0-9])\2){3}$/;
+    regHEX = /^\#(([a-fA-F0-9])\2){3}$/,
+    none = /\bnone\b/i;
 
 /**
  * Convert different colors formats in element attributes to hex.
@@ -56,6 +58,11 @@ exports.fn = function(item, params) {
                 var val = attr.value,
                     match;
 
+                // Convert colors to currentColor
+                if (params.currentColor && (match = !val.match(none))) {
+                    val = 'currentColor';
+                }
+
                 // Convert color name keyword to long hex
                 if (params.names2hex && val.toLowerCase() in collections.colorsNames) {
                     val = collections.colorsNames[val.toLowerCase()];


Test patch:
diff --git a/test/plugins/convertColors.04.svg b/test/plugins/convertColors.04.svg
new file mode 100644
index 0000000..4eb6d41
--- /dev/null
+++ b/test/plugins/convertColors.04.svg
@@ -0,0 +1,25 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+    <g color="black"/>
+    <g color="BLACK"/>
+    <g color="none"/>
+    <path fill="rgb(64, 64, 64)"/>
+    <path fill="rgb(86.27451%,86.666667%,87.058824%)"/>
+    <path fill="rgb(-255,100,500)"/>
+    <path fill="none"/>
+</svg>
+
+@@@
+
+<svg xmlns="http://www.w3.org/2000/svg">
+    <g color="currentColor"/>
+    <g color="currentColor"/>
+    <g color="none"/>
+    <path fill="currentColor"/>
+    <path fill="currentColor"/>
+    <path fill="currentColor"/>
+    <path fill="none"/>
+</svg>
+
+@@@
+
+{ "currentColor": true }
\ No newline at end of file
Repository: svg/svgo
Pull request #579 (2016-08-24 23:11:37)

Improve sortAttrs plugin
This fixes some annoyances with sortAttrs:

- Attributes such as `stroke-linejoin` were not included with `stroke-width`, `stroke-miterlimit` etc.. Now all attributes that begin with `stroke-` are sorted alphabetically immediately after `stroke`. Same for fill and marker attributes.
- Prefixed attributes are moved to the end of the list, except `xmlns`, which is still at the start.
- Any attributes not listed in the order are sorted alphabetically.


Patch:
diff --git a/plugins/sortAttrs.js b/plugins/sortAttrs.js
index 29897f1..221a4bf 100644
--- a/plugins/sortAttrs.js
+++ b/plugins/sortAttrs.js
@@ -8,14 +8,12 @@ exports.description = 'sorts element attributes (disabled by default)';
 
 exports.params = {
 	order: [
-		'xmlns',
 		'id',
 		'width', 'height',
 		'x', 'x1', 'x2',
 		'y', 'y1', 'y2',
 		'cx', 'cy', 'r',
-		'fill', 'fill-opacity', 'fill-rule',
-		'stroke', 'stroke-opacity', 'stroke-width', 'stroke-miterlimit', 'stroke-dashoffset',
+		'fill', 'stroke', 'marker',
 		'd', 'points'
 	]
 };
@@ -41,8 +39,35 @@ exports.fn = function(item, params) {
 		});
 
 		attrs.sort(function(a, b) {
-			return ((a = params.order.indexOf(a.name)) > -1 ? a : orderlen) -
-				((b = params.order.indexOf(b.name)) > -1 ? b : orderlen);
+			if (a.prefix != b.prefix) {
+				// xmlns attributes implicitly have the prefix xmlns
+				if (a.prefix == 'xmlns')
+					return -1;
+				if (b.prefix == 'xmlns')
+					return 1;
+				return a.prefix < b.prefix ? -1 : 1;
+			}
+
+			var aindex = orderlen;
+			var bindex = orderlen;
+
+			for (var i = 0; i < params.order.length; i++) {
+				if (a.name == params.order[i]) {
+					aindex = i;
+				} else if (a.name.indexOf(params.order[i] + '-') === 0) {
+					aindex = i + .5;
+				}
+				if (b.name == params.order[i]) {
+					bindex = i;
+				} else if (b.name.indexOf(params.order[i] + '-') === 0) {
+					bindex = i + .5;
+				}
+			}
+
+			if (aindex != bindex) {
+				return aindex - bindex;
+			}
+			return a.name < b.name ? -1 : 1;
 		});
 
 		attrs.forEach(function (attr) {


Test patch:
diff --git a/test/plugins/sortAttrs.01.svg b/test/plugins/sortAttrs.01.svg
index f1bd577..58281c8 100644
--- a/test/plugins/sortAttrs.01.svg
+++ b/test/plugins/sortAttrs.01.svg
@@ -1,9 +1,11 @@
 <svg foo="bar" xmlns="http://www.w3.org/2000/svg" height="10" baz="quux" width="10" hello="world">
+    <rect x="0" y="0" width="100" height="100" stroke-width="1" stroke-linejoin="round" fill="red" stroke="orange" xmlns="http://www.w3.org/2000/svg"/>
     test
 </svg>
 
 @@@
 
-<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" foo="bar" baz="quux" hello="world">
+<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" baz="quux" foo="bar" hello="world">
+    <rect xmlns="http://www.w3.org/2000/svg" width="100" height="100" x="0" y="0" fill="red" stroke="orange" stroke-linejoin="round" stroke-width="1"/>
     test
 </svg>
Repository: svg/svgo
Pull request #742 (2017-06-14 10:04:01)

fix viewBox round
@GreLI I did a stupid mistake, sorry, added a test


Patch:
diff --git a/plugins/cleanupNumericValues.js b/plugins/cleanupNumericValues.js
index af36431..e91fdf2 100644
--- a/plugins/cleanupNumericValues.js
+++ b/plugins/cleanupNumericValues.js
@@ -41,8 +41,9 @@ exports.fn = function(item, params) {
 
         if (item.hasAttr('viewBox')) {
             var nums = item.attr('viewBox').value.split(/[ ,]/g);
-            item.attr('viewBox').value = nums.map(function(num) {
-                return +num.toFixed(floatPrecision);
+            item.attr('viewBox').value = nums.map(function(value) {
+                var num = +value;
+                return isNaN(num) ? value : +num.toFixed(floatPrecision);
             }).join(' ');
         }
 


Test patch:
diff --git a/test/plugins/cleanupNumericValues.01.svg b/test/plugins/cleanupNumericValues.01.svg
index 62bf658..389a8c4 100644
--- a/test/plugins/cleanupNumericValues.01.svg
+++ b/test/plugins/cleanupNumericValues.01.svg
@@ -1,9 +1,9 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="50.12356%" height="20px" x=".2655" y="-.2346">
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="20.000001 -19.99999 17.123456 70.708090" width="50.12356%" height="20px" x=".2655" y="-.2346">
     <rect width="1in" heigth="12pt"/>
 </svg>
 
 @@@
 
-<svg xmlns="http://www.w3.org/2000/svg" width="50.124%" height="20" x=".266" y="-.235">
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="20 -20 17.123 70.708" width="50.124%" height="20" x=".266" y="-.235">
     <rect width="96" heigth="16"/>
 </svg>
Repository: svg/svgo
Pull request #760 (2017-07-13 00:16:37)

Closes svg/svgo#759. Upper case hex color now converts to shortname.


Patch:
diff --git a/plugins/convertColors.js b/plugins/convertColors.js
index b856e13..77279e9 100644
--- a/plugins/convertColors.js
+++ b/plugins/convertColors.js
@@ -95,8 +95,11 @@ exports.fn = function(item, params) {
                 }
 
                 // Convert hex to short name
-                if (params.shortname && val in collections.colorsShortNames) {
-                    val = collections.colorsShortNames[val];
+                if (params.shortname) {
+                    var lowerVal = val.toLowerCase();
+                    if (lowerVal in collections.colorsShortNames) {
+                        val = collections.colorsShortNames[lowerVal];
+                    }
                 }
 
                 attr.value = val;


Test patch:
diff --git a/test/plugins/convertColors.03.svg b/test/plugins/convertColors.03.svg
index 3f84b6b..000e79e 100644
--- a/test/plugins/convertColors.03.svg
+++ b/test/plugins/convertColors.03.svg
@@ -1,5 +1,5 @@
 <svg xmlns="http://www.w3.org/2000/svg">
-    <g color="#ff0000"/>
+    <g color="#FF0000"/>
     <g color="#f00"/>
 </svg>
Repository: svg/svgo
Pull request #984 (2018-06-14 22:23:40)

[plugin] sortAttrs: add xmlns order option
i wanted this option so that `xmlns` attributes weren't always at the front of the node.


Patch:
diff --git a/plugins/sortAttrs.js b/plugins/sortAttrs.js
index 221a4bf..cba5c1d 100644
--- a/plugins/sortAttrs.js
+++ b/plugins/sortAttrs.js
@@ -30,7 +30,8 @@ exports.fn = function(item, params) {
 
 	var attrs = [],
 		sorted = {},
-		orderlen = params.order.length + 1;
+		orderlen = params.order.length + 1,
+		xmlnsOrder = params.xmlnsOrder || 'front';
 
 	if (item.elem) {
 
@@ -41,10 +42,12 @@ exports.fn = function(item, params) {
 		attrs.sort(function(a, b) {
 			if (a.prefix != b.prefix) {
 				// xmlns attributes implicitly have the prefix xmlns
-				if (a.prefix == 'xmlns')
-					return -1;
-				if (b.prefix == 'xmlns')
-					return 1;
+				if (xmlnsOrder == 'front') {
+                    if (a.prefix == 'xmlns')
+                        return -1;
+                    if (b.prefix == 'xmlns')
+                        return 1;
+                }
 				return a.prefix < b.prefix ? -1 : 1;
 			}
 


Test patch:
diff --git a/test/plugins/sortAttrs.02.svg b/test/plugins/sortAttrs.02.svg
new file mode 100644
index 0000000..3237551
--- /dev/null
+++ b/test/plugins/sortAttrs.02.svg
@@ -0,0 +1,15 @@
+<svg foo="bar" xmlns="http://www.w3.org/2000/svg" height="10" baz="quux" width="10" hello="world">
+    <rect x="0" y="0" width="100" height="100" stroke-width="1" stroke-linejoin="round" fill="red" stroke="orange" xmlns="http://www.w3.org/2000/svg"/>
+    test
+</svg>
+
+@@@
+
+<svg width="10" height="10" baz="quux" foo="bar" hello="world" xmlns="http://www.w3.org/2000/svg">
+    <rect width="100" height="100" x="0" y="0" fill="red" stroke="orange" stroke-linejoin="round" stroke-width="1" xmlns="http://www.w3.org/2000/svg"/>
+    test
+</svg>
+
+@@@
+
+{ "xmlnsOrder": "alphabetical" }
Repository: ceph/go-ceph
Pull request #530 (2021-07-08 14:46:53)

cephfs: add ReadConfigFile implementing ceph_conf_read_file 
Add a ReadConfigFile function that accepts a path to a config file. This will be especially handy when we need to connect to multiple ceph clusters from one (go-ceph test) function.


## Checklist
- [x] Added tests for features and functional changes
- [x] Public functions and types are documented
- [x] Standard formatting is applied to Go code


phlogistonjohn: @nixpanic or @agarwal-mudit PTAL when you have a moment. Other PRs depend on this work.

Patch:
diff --git a/cephfs/cephfs.go b/cephfs/cephfs.go
index b90f894..d8132c6 100644
--- a/cephfs/cephfs.go
+++ b/cephfs/cephfs.go
@@ -64,12 +64,26 @@ func CreateFromRados(conn *rados.Conn) (*MountInfo, error) {
 	return mount, nil
 }
 
-// ReadDefaultConfigFile loads the ceph configuration from the specified config file.
+// ReadDefaultConfigFile loads the ceph configuration from the default config file.
+//
+// Implements:
+//  int ceph_conf_read_file(struct ceph_mount_info *cmount, const char *path_list);
 func (mount *MountInfo) ReadDefaultConfigFile() error {
 	ret := C.ceph_conf_read_file(mount.mount, nil)
 	return getError(ret)
 }
 
+// ReadConfigFile loads the ceph configuration from the specified config file.
+//
+// Implements:
+//  int ceph_conf_read_file(struct ceph_mount_info *cmount, const char *path_list);
+func (mount *MountInfo) ReadConfigFile(path string) error {
+	cPath := C.CString(path)
+	defer C.free(unsafe.Pointer(cPath))
+	ret := C.ceph_conf_read_file(mount.mount, cPath)
+	return getError(ret)
+}
+
 // ParseConfigArgv configures the mount using a unix style command line
 // argument vector.
 //


Test patch:
diff --git a/cephfs/cephfs_test.go b/cephfs/cephfs_test.go
index f380c99..3bec5c0 100644
--- a/cephfs/cephfs_test.go
+++ b/cephfs/cephfs_test.go
@@ -2,6 +2,8 @@ package cephfs
 
 import (
 	"fmt"
+	"io"
+	"io/ioutil"
 	"os"
 	"testing"
 	"time"
@@ -332,3 +334,26 @@ func TestValidate(t *testing.T) {
 		assert.Equal(t, err, ErrNotConnected)
 	})
 }
+
+func TestReadConfigFile(t *testing.T) {
+	file, err := ioutil.TempFile("/tmp", "cephfs.conf")
+	require.NoError(t, err)
+	defer func() {
+		assert.NoError(t, file.Close())
+		assert.NoError(t, os.Remove(file.Name()))
+	}()
+	_, err = io.WriteString(
+		file, "[global]\nfsid = 04862775-14d5-46e0-a015-000000000000\n")
+	require.NoError(t, err)
+
+	mount, err := CreateMount()
+	require.NoError(t, err)
+	require.NotNil(t, mount)
+
+	err = mount.ReadConfigFile(file.Name())
+	require.NoError(t, err)
+
+	v, err := mount.GetConfigOption("fsid")
+	assert.NoError(t, err)
+	assert.Equal(t, "04862775-14d5-46e0-a015-000000000000", v)
+}
Repository: ceph/go-ceph
Pull request #570 (2021-09-07 00:10:37)

cephfs : add missing cephfs API components: fuction ceph_version
cephfs: add missing cephfs API Components: function ceph_version 

Signed-off-by: yjkim <oct28.yjkim@gmail.com]>

## Checklist
- [O] Added tests for features and functional changes
- [O] Public functions and types are documented
- [O] Standard formatting is applied to Go code


oct28-yjkim: 265 is project isseue number. that was my fault. 
i fixed commit msg. 
please review this PR.
phlogistonjohn: > 265 is project isseue number. that was my fault.
> i fixed commit msg.
> please review this PR.

Understood.  Unfortunately, the commit message appears unchanged at the moment.
phlogistonjohn: @mergifyio rebase
mergify[bot]: **Command `rebase`: success**
> **Branch has been successfully rebased**
> 

phlogistonjohn: @ansiwen I just rebased this PR. When it's done could you please take a look when you have a moment? thank you
ansiwen: Unfortunately CI is failing.
ansiwen: Actually, our new [API policy](https://github.com/ceph/go-ceph/blob/master/docs/api-stability.md) would require this to be tagged as "preview". But it is so simple, that I have no issue merging it as stable. Also I'm not 100% sure, when we will start to enforce the new policy.
ansiwen: @mergifyio rebase
mergify[bot]: **Command `rebase`: success**
> **Branch has been successfully rebased**
> 


Patch:
diff --git a/cephfs/cephfs.go b/cephfs/cephfs.go
index d8132c6..7554e11 100644
--- a/cephfs/cephfs.go
+++ b/cephfs/cephfs.go
@@ -37,6 +37,13 @@ func (mount *MountInfo) validate() error {
 	return nil
 }
 
+// Version returns the major, minor, and patch level of the libcephfs library.
+func Version() (int, int, int) {
+	var cMajor, cMinor, cPatch C.int
+	C.ceph_version(&cMajor, &cMinor, &cPatch)
+	return int(cMajor), int(cMinor), int(cPatch)
+}
+
 // CreateMount creates a mount handle for interacting with Ceph.
 func CreateMount() (*MountInfo, error) {
 	return createMount(nil)


Test patch:
diff --git a/cephfs/cephfs_test.go b/cephfs/cephfs_test.go
index 3bec5c0..fc2acda 100644
--- a/cephfs/cephfs_test.go
+++ b/cephfs/cephfs_test.go
@@ -357,3 +357,10 @@ func TestReadConfigFile(t *testing.T) {
 	assert.NoError(t, err)
 	assert.Equal(t, "04862775-14d5-46e0-a015-000000000000", v)
 }
+
+func TestVersion(t *testing.T) {
+	var major, minor, patch = Version()
+	assert.False(t, major < 0 || major > 1000, "invalid major")
+	assert.False(t, minor < 0 || minor > 1000, "invalid minor")
+	assert.False(t, patch < 0 || patch > 1000, "invalid patch")
+}