nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: mbrt/gmailctl
Pull request #302 (2022-11-10 13:39:42)

Quote plus sign automatically.
Gmail has this weird behavior:

* `from: foo+bar` is equivalent to `from:foo OR from:bar`
* `from foo+bar@google.com` is not (just searches the full address).

This change accounts for this behavior and automatically quotes the
plus sign, only when outside of full email addresses. This should match
users expectations a lot better.


Patch:
diff --git a/internal/engine/filter/convert.go b/internal/engine/filter/convert.go
index c55ad3f..34dd1da 100644
--- a/internal/engine/filter/convert.go
+++ b/internal/engine/filter/convert.go
@@ -228,27 +228,33 @@ func joinQueries(f1, f2 string) string {
 
 func joinStrings(escape bool, a ...string) string {
 	if escape {
-		return joinEscaped(a...)
+		return joinQuoted(a...)
 	}
 	return strings.Join(a, " ")
 }
 
-func joinEscaped(a ...string) string {
-	return strings.Join(escapeStrings(a...), " ")
+func joinQuoted(a ...string) string {
+	return strings.Join(quoteStrings(a...), " ")
 }
 
-func escapeStrings(a ...string) []string {
+func quoteStrings(a ...string) []string {
 	res := make([]string, len(a))
 	for i, s := range a {
-		res[i] = escape(s)
+		res[i] = quote(s)
 	}
 	return res
 }
 
-func escape(a string) string {
+func quote(a string) string {
 	if strings.ContainsAny(a, " \t{}()") {
 		return fmt.Sprintf(`"%s"`, a)
 	}
+	// We need to quote the plus sign, _unless_ it's within a full email
+	// address. This is necessary because "foo+bar" is considered like
+	// "foo OR bar", but "foo+bar@gmail.com" is not.
+	if strings.Contains(a, "+") && !strings.Contains(a, "@") {
+		return fmt.Sprintf(`"%s"`, a)
+	}
 	return a
 }
 
@@ -448,7 +454,7 @@ func generateActions(actions parser.Actions) ([]Actions, error) {
 	}
 
 	if fromOptionalBool(actions.MarkSpam, true) {
-		return nil, errors.New("Gmail filters don't allow one to send messages to spam directly")
+		return nil, errors.New("gmail filters don't allow one to send messages to spam directly")
 	}
 
 	if len(actions.Labels) == 0 {


Test patch:
diff --git a/internal/engine/filter/convert_test.go b/internal/engine/filter/convert_test.go
index 773359a..a05d4cb 100644
--- a/internal/engine/filter/convert_test.go
+++ b/internal/engine/filter/convert_test.go
@@ -13,23 +13,29 @@ func boolptr(a bool) *bool {
 	return &a
 }
 
-func TestSimpleFilter(t *testing.T) {
+func TestQuotes(t *testing.T) {
 	rules := []parser.Rule{
 		{
 			Criteria: &parser.Leaf{
 				Function: parser.FunctionFrom,
 				Grouping: parser.OperationOr,
-				Args:     []string{"a", "b", "with spaces"},
+				Args: []string{
+					"a",
+					"with spaces",
+					"with+plus",
+					"with+plus@email.com",
+				},
 			},
 			Actions: parser.Actions{
 				Archive: true,
 			},
 		},
 	}
+	// The plus sign is quoted, except for when in full email addresses.
 	expected := Filters{
 		{
 			Criteria: Criteria{
-				From: `{a b "with spaces"}`,
+				From: `{a "with spaces" "with+plus" with+plus@email.com}`,
 			},
 			Action: Actions{
 				Archive: true,
Repository: mdlayher/netlink
Pull request #139 (2019-05-30 07:25:39)

Add socket option NETLINK_EXT_ACK
Signed-off-by: Lehner Florian <dev@der-flo.net>

This PR adds support for the socket option NETLINK_EXT_ACK. 

https://lwn.net/Articles/719721/


Patch:
diff --git a/conn.go b/conn.go
index 3a1a739..59b2384 100644
--- a/conn.go
+++ b/conn.go
@@ -428,6 +428,7 @@ const (
 	NoENOBUFS
 	ListenAllNSID
 	CapAcknowledge
+	ExtendedAcknowledge
 )
 
 // An optionSetter is a Socket that supports setting netlink options.
diff --git a/conn_linux.go b/conn_linux.go
index ff02891..4bee052 100644
--- a/conn_linux.go
+++ b/conn_linux.go
@@ -305,6 +305,8 @@ func linuxOption(o ConnOption) (int, bool) {
 		return unix.NETLINK_LISTEN_ALL_NSID, true
 	case CapAcknowledge:
 		return unix.NETLINK_CAP_ACK, true
+	case ExtendedAcknowledge:
+		return unix.NETLINK_EXT_ACK, true
 	default:
 		return 0, false
 	}


Test patch:
diff --git a/conn_linux_test.go b/conn_linux_test.go
index 0983658..5f6f246 100644
--- a/conn_linux_test.go
+++ b/conn_linux_test.go
@@ -370,6 +370,15 @@ func TestLinuxConnSetOption(t *testing.T) {
 				value: 1,
 			},
 		},
+		{
+			name:   "extended ACK reporting",
+			option: ExtendedAcknowledge,
+			enable: true,
+			want: setSockopt{
+				opt:   unix.NETLINK_EXT_ACK,
+				value: 1,
+			},
+		},
 	}
 
 	for _, tt := range tests {
Repository: mdlayher/netlink
Pull request #153 (2019-10-07 17:56:09)

Add NLA_FLAG
Signed-off-by: Lehner Florian <dev@der-flo.net>

This PR adds the attribute type NLA_FLAG.

NLA_FLAG does not hold data. It is used in the net/tipc netlink family.


Patch:
diff --git a/attribute.go b/attribute.go
index 1e40a72..16cce6b 100644
--- a/attribute.go
+++ b/attribute.go
@@ -280,6 +280,11 @@ func (ad *AttributeDecoder) Uint64() uint64 {
 	return ad.ByteOrder.Uint64(b)
 }
 
+// Flag returns a boolean representing the Attribute.
+func (ad *AttributeDecoder) Flag() bool {
+	return ad.err == nil
+}
+
 // Do is a general purpose function which allows access to the current data
 // pointed to by the AttributeDecoder.
 //
@@ -384,6 +389,18 @@ func (ae *AttributeEncoder) Uint64(typ uint16, v uint64) {
 	})
 }
 
+// Flag encodes a flag into an Attribute specidied by typ.
+func (ae *AttributeEncoder) Flag(typ uint16, v bool) {
+	if ae.err != nil {
+		return
+	}
+	if !v {
+		return
+	}
+
+	ae.attrs = append(ae.attrs, Attribute{Type: typ})
+}
+
 // String encodes string s as a null-terminated string into an Attribute
 // specified by typ.
 func (ae *AttributeEncoder) String(typ uint16, s string) {


Test patch:
diff --git a/attribute_test.go b/attribute_test.go
index ffccb15..f85175c 100644
--- a/attribute_test.go
+++ b/attribute_test.go
@@ -575,6 +575,24 @@ func TestAttributeDecoderOK(t *testing.T) {
 				}
 			},
 		},
+		{
+			name: "flag",
+			attrs: []Attribute{{
+				Type: 1,
+			}},
+			fn: func(ad *AttributeDecoder) {
+				var flag bool
+				switch t := ad.Type(); t {
+				case 1:
+					flag = ad.Flag()
+				default:
+					panicf("unhandled attribute type: %d", t)
+				}
+				if flag != true {
+					panicf("unexpected attribute value (-want +got):\n -want: true\n +got: false")
+				}
+			},
+		},
 		{
 			name: "do",
 			attrs: []Attribute{
@@ -805,6 +823,20 @@ func TestAttributeEncoderOK(t *testing.T) {
 			endian: binary.BigEndian,
 			fn:     aeEndianTest(binary.BigEndian),
 		},
+		{
+			name:  "flag true",
+			attrs: []Attribute{{Type: 1}},
+			fn: func(ae *AttributeEncoder) {
+				ae.Flag(1, true)
+			},
+		},
+		{
+			name:  "flag false",
+			attrs: []Attribute{},
+			fn: func(ae *AttributeEncoder) {
+				ae.Flag(1, false)
+			},
+		},
 		{
 			name: "string",
 			attrs: []Attribute{{
Repository: nvim-lua/plenary.nvim
Pull request #125 (2021-04-05 14:50:54)

fix: recursive rm deletes hidden dirs too


Patch:
diff --git a/lua/plenary/job.lua b/lua/plenary/job.lua
index ffdb5f3..14b97b0 100644
--- a/lua/plenary/job.lua
+++ b/lua/plenary/job.lua
@@ -468,7 +468,11 @@ function Job:wait(timeout, wait_interval, should_redraw)
   wait_interval = wait_interval or 10
 
   if self.handle == nil then
-    vim.api.nvim_err_writeln(vim.inspect(self))
+    local msg = vim.inspect(self)
+    vim.schedule(function()
+      vim.api.nvim_err_writeln(msg)
+    end)
+
     return
   end
 
@@ -555,6 +559,7 @@ end
 
 function Job:after(fn)
   self:add_on_exit_callback(fn)
+  return self
 end
 
 function Job:and_then_on_success(next_job)
diff --git a/lua/plenary/path.lua b/lua/plenary/path.lua
index 675e4aa..8d7376d 100644
--- a/lua/plenary/path.lua
+++ b/lua/plenary/path.lua
@@ -422,7 +422,7 @@ function Path:rm(opts)
     -- first unlink all files
     scan.scan_dir(abs, { hidden = true, on_insert = function(file) uv.fs_unlink(file) end})
 
-    local dirs = scan.scan_dir(abs, { add_dirs = true })
+    local dirs = scan.scan_dir(abs, { add_dirs = true, hidden = true })
     -- iterate backwards to clean up remaining dirs
     for i = #dirs, 1, -1 do
       uv.fs_rmdir(dirs[i])


Test patch:
diff --git a/tests/plenary/job_spec.lua b/tests/plenary/job_spec.lua
index b239549..809bce3 100644
--- a/tests/plenary/job_spec.lua
+++ b/tests/plenary/job_spec.lua
@@ -392,8 +392,7 @@ describe('Job', function()
 
       local second_job = Job:new{ command = 'false' }
 
-      first_job:after(function() code = code + 10 end)
-      first_job:and_then(second_job)
+      first_job:after(function() code = code + 10 end):and_then(second_job)
       second_job:after(function(_, c) code = code + c end)
 
       first_job:sync()
diff --git a/tests/plenary/path_spec.lua b/tests/plenary/path_spec.lua
index 0b12a72..4eb509a 100644
--- a/tests/plenary/path_spec.lua
+++ b/tests/plenary/path_spec.lua
@@ -237,14 +237,18 @@ describe('Path', function()
     it('does create dirs if nested in none existing dirs', function()
       local p1 = Path:new({ "nested", "nested2", "test_file.lua" })
       local p2 = Path:new({ "nested", "asdf", ".hidden" })
+      local d1 = Path:new({ "nested", "dir", ".hidden" })
       assert(pcall(p1.touch, p1, { parents = true }))
       assert(pcall(p2.touch, p2, { parents = true }))
+      assert(pcall(d1.mkdir, d1, { parents = true }))
       assert(p1:exists())
       assert(p2:exists())
+      assert(d1:exists())
 
       Path:new({ "nested" }):rm({ recursive = true })
       assert(not p1:exists())
       assert(not p2:exists())
+      assert(not d1:exists())
       assert(not Path:new({ "nested" }):exists())
     end)
   end)
Repository: nvim-lua/plenary.nvim
Pull request #126 (2021-04-05 16:30:50)

feat(api-signature): Jobs after return self
I know there are plenty of other that could possibly return self, but I
wanted to just throw this out there as a starting point.


Patch:
diff --git a/lua/plenary/job.lua b/lua/plenary/job.lua
index ffdb5f3..48b6a14 100644
--- a/lua/plenary/job.lua
+++ b/lua/plenary/job.lua
@@ -555,6 +555,7 @@ end
 
 function Job:after(fn)
   self:add_on_exit_callback(fn)
+  return self
 end
 
 function Job:and_then_on_success(next_job)


Test patch:
diff --git a/tests/plenary/job_spec.lua b/tests/plenary/job_spec.lua
index b239549..809bce3 100644
--- a/tests/plenary/job_spec.lua
+++ b/tests/plenary/job_spec.lua
@@ -392,8 +392,7 @@ describe('Job', function()
 
       local second_job = Job:new{ command = 'false' }
 
-      first_job:after(function() code = code + 10 end)
-      first_job:and_then(second_job)
+      first_job:after(function() code = code + 10 end):and_then(second_job)
       second_job:after(function(_, c) code = code + c end)
 
       first_job:sync()
Repository: nvim-lua/plenary.nvim
Pull request #128 (2021-04-07 11:08:44)

Fix shebang detection for bash
Please see https://github.com/nvim-telescope/telescope.nvim/issues/721 for more information. I tried the solution @Conni2461 suggested and it did fix the issue.

Conni2461: Can you also fix the corresponding test? `tests/plenary/filetype_spec.lua:81`
marioortizmanero: Done

Patch:
diff --git a/data/plenary/filetypes/builtin.lua b/data/plenary/filetypes/builtin.lua
index d826d1a..512b884 100644
--- a/data/plenary/filetypes/builtin.lua
+++ b/data/plenary/filetypes/builtin.lua
@@ -1,7 +1,7 @@
 local shebang_prefixes = { '/usr/bin/', '/bin/', '/usr/bin/env ', '/bin/env ' }
 local shebang_fts = {
   ['sh'] = 'sh',
-  ['bash'] = 'bash',
+  ['bash'] = 'sh',
   ['zsh'] = 'zsh',
   ['python'] = 'python',
   ['python2'] = 'python',
diff --git a/lua/plenary/job.lua b/lua/plenary/job.lua
index 14b97b0..267dd35 100644
--- a/lua/plenary/job.lua
+++ b/lua/plenary/job.lua
@@ -48,8 +48,9 @@ end
 
 local function expand(path)
   if vim.in_fast_event() then
-    return uv.fs_realpath(path)
+    return assert(uv.fs_realpath(path), string.format("Path must be valid: %s", path))
   else
+    -- TODO: Probably want to check that this is valid here... otherwise that's weird.
     return vim.fn.expand(path, true)
   end
 end
@@ -108,7 +109,7 @@ function Job:new(o)
 
   obj.command = command
   obj.args = args
-  obj.cwd = o.cwd and expand(o.cwd)
+  obj._raw_cwd = o.cwd
   if o.env then
     if type(o.env) ~= "table" then error('[plenary.job] env has to be a table') end
 
@@ -264,7 +265,7 @@ function Job:_create_uv_options()
   options.args = self.args
   options.stdio = { self.stdin, self.stdout, self.stderr }
 
-  if self.cwd then options.cwd = self.cwd end
+  if self._raw_cwd then options.cwd = expand(self._raw_cwd) end
   if self.env then options.env = self.env end
 
   return options


Test patch:
diff --git a/tests/plenary/filetype_spec.lua b/tests/plenary/filetype_spec.lua
index eaa2ae2..fc0e7b7 100644
--- a/tests/plenary/filetype_spec.lua
+++ b/tests/plenary/filetype_spec.lua
@@ -78,7 +78,7 @@ describe('filetype', function()
     end)
 
     it('should work for bash', function()
-      assert.are.same('bash', filetype._parse_shebang('#!/bin/bash'))
+      assert.are.same('sh', filetype._parse_shebang('#!/bin/bash'))
     end)
 
     it('should work for usr/bin/env shell', function()
Repository: JuliaGeo/LibGEOS.jl
Pull request #145 (2022-11-09 06:46:42)

expose clone


Patch:
diff --git a/src/geos_types.jl b/src/geos_types.jl
index b2506e2..ed24b85 100644
--- a/src/geos_types.jl
+++ b/src/geos_types.jl
@@ -12,6 +12,7 @@ and that shared context is returned. If contexts of some geometries differ,
 an error is thrown.
 """
 function get_context end
+
 function get_context(gs::AbstractVector)::GEOSContext
     if isempty(gs)
         get_global_context() # is this a good idea?
@@ -304,6 +305,18 @@ const Geometry = Union{
     GeometryCollection,
 }
 
+"""
+    clone(obj::Geometry, context=get_context(obj))
+
+Create a deep copy of obj, optionally also moving it to a new context.
+"""
+function clone(obj::Geometry, context=get_context(obj))
+    G = typeof(obj)
+    # Note that all Geometry constructors 
+    # implicitly clone the pointer, in the following line
+    GC.@preserve obj G(obj.ptr, context)::G
+end
+
 get_context(obj::Geometry) = obj.context
 function destroyGeom(obj::Geometry)
     context = get_context(obj)


Test patch:
diff --git a/test/test_geos_types.jl b/test/test_geos_types.jl
index 04cff68..f1bafc7 100644
--- a/test/test_geos_types.jl
+++ b/test/test_geos_types.jl
@@ -369,4 +369,39 @@ end
         return nothing
     end
     f91(91)
+    @testset "clone" begin
+        function f(n)
+            # adapted from https://github.com/JuliaGeo/LibGEOS.jl/issues/91#issuecomment-1267732709
+            contexts = [LibGEOS.GEOSContext() for i=1:Threads.nthreads()]
+            p = LibGEOS.Polygon([[[-1.,-1],[+1,-1],[+1,+1],[-1,+1],[-1,-1]]])
+            Threads.@threads :static for i=1:n
+                ctx = contexts[Threads.threadid()]
+                g1 = LibGEOS.clone(p,ctx)
+                g2 = LibGEOS.clone(p,ctx)
+                for j=1:n
+                    intersects(g1,g2)
+                end
+            end
+            GC.gc(true)
+            return nothing
+        end
+        f(91)
+    end
+end
+
+@testset "clone" begin
+    geos = [
+        readgeom("POINT(0 0)")
+        readgeom("MULTIPOINT(0 0, 5 0, 10 0)")
+        readgeom("LINESTRING (130 240, 650 240)")
+        readgeom("POLYGON EMPTY")
+        readgeom("POLYGON ((10 10, 20 40, 90 90, 90 10, 10 10))")
+        readgeom("MULTILINESTRING ((5 0, 10 0), (0 0, 5 0))")
+        readgeom("GEOMETRYCOLLECTION (LINESTRING (1 2, 2 2), LINESTRING (2 1, 1 1), POLYGON ((0.5 1, 1 2, 1 1, 0.5 1)), POLYGON ((9 2, 9.5 1, 2 1, 2 2, 9 2)))")
+    ]
+    for g1 in geos
+        g2 = LibGEOS.clone(g1)
+        @test g1 !== g2
+        @test LibGEOS.equals(g1,g2)
+    end
 end
diff --git a/test/test_misc.jl b/test/test_misc.jl
index 34cd1a5..9c56950 100644
--- a/test/test_misc.jl
+++ b/test/test_misc.jl
@@ -36,4 +36,3 @@ end
     @test_throws ArgumentError LibGEOS.intersects(p1, q2)
     @test_throws ArgumentError LibGEOS.intersects(p2, q1)
 end
-
Repository: JuliaGeo/LibGEOS.jl
Pull request #192 (2024-01-01 20:32:22)

Ignore RecipesBase ambiguity in Aqua.jl checks
We cant fix this without adding a method to RecipesBase.jl

For now, lets skip the check.


Patch:
diff --git a/Project.toml b/Project.toml
index 5df8fa4..7b56082 100644
--- a/Project.toml
+++ b/Project.toml
@@ -11,17 +11,22 @@ GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
 GeoInterfaceRecipes = "0329782f-3d07-4b52-b9f6-d3137cf03c7a"
 
 [compat]
+Aqua = "0.8"
 CEnum = "0.2, 0.3, 0.4, 0.5"
 Extents = "0.1.1"
 GEOS_jll = "3.12"
 GeoInterface = "1"
 GeoInterfaceRecipes = "1"
+Plots = "1"
+RecipesBase = "1"
+Test = "1"
 julia = "1.6"
 
 [extras]
 Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
 Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
+RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
 Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
 
 [targets]
-test = ["Aqua", "Plots", "Test"]
+test = ["Aqua", "Plots", "RecipesBase", "Test"]


Test patch:
diff --git a/test/runtests.jl b/test/runtests.jl
index f0b222c..058c507 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -1,5 +1,5 @@
 using GeoInterface, Extents
-using Test, LibGEOS
+using Test, LibGEOS, RecipesBase
 import Aqua
 
 version = LibGEOS.GEOSversion()
@@ -14,6 +14,9 @@ if version != LibGEOS.GEOS_CAPI_VERSION
 end
 
 @testset "LibGEOS" begin
+    Aqua.test_all(LibGEOS;
+        ambiguities=(exclude=[RecipesBase.apply_recipe],),
+    )
     include("test_geos_types.jl")
     include("test_geos_functions.jl")
     include("test_geos_operations.jl")
@@ -22,5 +25,4 @@ end
     include("test_invalid_geometry.jl")
     include("test_strtree.jl")
     include("test_misc.jl")
-    Aqua.test_all(LibGEOS)
 end