nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: fredrikekre/Runic.jl
Pull request #88 (2024-10-31 16:26:20)

Relax toggle comments to allow more "pragmas"
This patch relaxes the toggle comments `# runic: (off|on)` such that the comment may contain more than just the toggle comment. This is useful when combining with other "pragmas" such as e.g. Literate.jl line filters. For example, the following now also toggles formatting:

```julia
# runic: off      #src
not = formatted   #src
# runic: on       #src
```


Patch:
diff --git a/README.md b/README.md
index 05e2ed0..b5f8601 100644
--- a/README.md
+++ b/README.md
@@ -318,7 +318,16 @@ Runic.
 
 The source comments `# runic: off` and `# runic: on` will toggle the formatting off and on,
 respectively. The comments must be on their own line, they must be on the same level in the
-syntax tree, and they must come in pairs.
+syntax tree, and they must come in pairs. An exception to the pairing rule is made at top
+level where a `# runic: off` comment will disable formatting for the remainder of the file.
+This is so that a full file can be excluded from formatting without having to add a
+`# runic: on` comment at the end of the file.
+
+> [!NOTE]
+> Note that it is enough that a comment contain the substring `# runic: off` or
+> `# runic: on` so that they can be combined with other "pragmas" such as e.g.
+> [Literate.jl line filters](https://fredrikekre.github.io/Literate.jl/v2/fileformat/#Filtering-lines)
+> like `#src`.
 
 > [!NOTE]
 > For compatibility with [JuliaFormatter](https://github.com/domluna/JuliaFormatter.jl) the
@@ -339,11 +348,6 @@ function foo()
 end
 ```
 
-An exception to the pairing rule is made at top level where a `# runic: off` comment will
-disable formatting for the remainder of the file. This is so that a full file can be
-excluded from formatting without having to add a `# runic: on` comment at the end of the
-file.
-
 ### Line width limit
 
 No. Use your <kbd>Enter</kbd> key or refactor your code.
diff --git a/src/Runic.jl b/src/Runic.jl
index e5de3d2..e777dd2 100644
--- a/src/Runic.jl
+++ b/src/Runic.jl
@@ -231,7 +231,7 @@ function check_format_toggle(ctx::Context, node::Node, kid::Node, i::Int)::Union
     # Check if the kid is a comment
     kind(kid) === K"Comment" || return nothing
     # Check the comment content
-    reg = r"^#(!)? (runic|format): (on|off)$"
+    reg = r"#(!)? (runic|format): (on|off)"
     str = String(read_bytes(ctx, kid))
     offmatch = match(reg, str)
     offmatch === nothing && return nothing


Test patch:
diff --git a/test/runtests.jl b/test/runtests.jl
index 76e56df..75e74da 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -1442,6 +1442,11 @@ end
                 return
             end
             """
+        # Extra stuff in the toggle comments
+        @test format_string("1+1\n$off #src\n1+1\n$on #src\n1+1") ==
+            "1 + 1\n$off #src\n1+1\n$on #src\n1 + 1"
+        @test format_string("1+1\n#src $off\n1+1\n#src $on\n1+1") ==
+            "1 + 1\n#src $off\n1+1\n#src $on\n1 + 1"
     end
 end
Repository: fredrikekre/Runic.jl
Pull request #89 (2024-10-31 16:52:23)

Fix whitespace before comment in operator formatting


Patch:
diff --git a/src/runestone.jl b/src/runestone.jl
index c48e0dc..3f88835 100644
--- a/src/runestone.jl
+++ b/src/runestone.jl
@@ -149,6 +149,8 @@ function spaces_around_x(ctx::Context, node::Node, is_x::F, n_leaves_per_x::Int
     looking_for_x = false
     n_x_leaves_visited = 0
 
+    peek(kids, i) = i < length(kids) ? kind(kids[i + 1]) : nothing
+
     for (i, kid) in pairs(kids)
         if kind(kid) === K"NewlineWs" ||
                 (i == 1 && kind(kid) === K"Whitespace")
@@ -160,7 +162,8 @@ function spaces_around_x(ctx::Context, node::Node, is_x::F, n_leaves_per_x::Int
             any_changes && push!(kids′, kid)
             looking_for_whitespace = false
         elseif looking_for_whitespace
-            if kind(kid) === K"Whitespace" && span(kid) == 1
+            if (kind(kid) === K"Whitespace" && span(kid) == 1) ||
+                    (kind(kid) === K"Whitespace" && peek(kids, i) === K"Comment" && peek(kids, i + 1) === K"NewlineWs")
                 # All good, just advance the IO
                 accept_node!(ctx, kid)
                 any_changes && push!(kids′, kid)


Test patch:
diff --git a/test/runtests.jl b/test/runtests.jl
index 75e74da..981cf26 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -182,8 +182,9 @@ end
             @test format_string("$(sp)a$(sp)$(op)$(sp)\nb$(sp)") ==
                 "$(sp)a $(op)\n    b$(sp)"
             # a op # comment \n b
+            minspace = sp == "" ? " " : sp
             @test format_string("$(sp)a$(sp)$(op)$(sp)# comment\nb$(sp)") ==
-                "$(sp)a $(op) # comment\n    b$(sp)"
+                "$(sp)a $(op)$(minspace)# comment\n    b$(sp)"
         end
         # Exceptions to the rule: `:`, `..`, and `^`
         # a:b
Repository: amacneil/dbmate
Pull request #202 (2021-03-06 04:16:56)

make the "invalid url" error message give more information
make the "invalid url" error message give more information for somebody that hasn't ready documentation and just runs the application

**Input**

```sh
dbmate up
```
**Output**

```
Error: invalid url, have you set your --url flag or DATABASE_HOST environment variable?
```

silbinarywolf: Fixed the tests failing too now :)

Patch:
diff --git a/pkg/dbmate/db.go b/pkg/dbmate/db.go
index b955686..815a5cb 100644
--- a/pkg/dbmate/db.go
+++ b/pkg/dbmate/db.go
@@ -72,7 +72,7 @@ func New(databaseURL *url.URL) *DB {
 // GetDriver initializes the appropriate database driver
 func (db *DB) GetDriver() (Driver, error) {
 	if db.DatabaseURL == nil || db.DatabaseURL.Scheme == "" {
-		return nil, errors.New("invalid url")
+		return nil, errors.New("invalid url, have you set your --url flag or DATABASE_URL environment variable?")
 	}
 
 	driverFunc := drivers[db.DatabaseURL.Scheme]


Test patch:
diff --git a/pkg/dbmate/db_test.go b/pkg/dbmate/db_test.go
index 0c07457..7b50daf 100644
--- a/pkg/dbmate/db_test.go
+++ b/pkg/dbmate/db_test.go
@@ -55,14 +55,14 @@ func TestGetDriver(t *testing.T) {
 		db := dbmate.New(nil)
 		drv, err := db.GetDriver()
 		require.Nil(t, drv)
-		require.EqualError(t, err, "invalid url")
+		require.EqualError(t, err, "invalid url, have you set your --url flag or DATABASE_URL environment variable?")
 	})
 
 	t.Run("missing schema", func(t *testing.T) {
 		db := dbmate.New(dbutil.MustParseURL("//hi"))
 		drv, err := db.GetDriver()
 		require.Nil(t, drv)
-		require.EqualError(t, err, "invalid url")
+		require.EqualError(t, err, "invalid url, have you set your --url flag or DATABASE_URL environment variable?")
 	})
 
 	t.Run("invalid driver", func(t *testing.T) {
Repository: amacneil/dbmate
Pull request #341 (2022-11-18 18:13:49)

Fixes typo in error message: up bock -> up block


Patch:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index f544654..7762056 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -9,7 +9,7 @@ jobs:
     name: Bump Homebrew formula
     runs-on: ubuntu-latest
     steps:
-      - uses: mislav/bump-homebrew-formula-action@v1
+      - uses: mislav/bump-homebrew-formula-action@v2
         with:
           formula-name: dbmate
         env:
diff --git a/pkg/dbmate/migration.go b/pkg/dbmate/migration.go
index 1a54308..4bb18ef 100644
--- a/pkg/dbmate/migration.go
+++ b/pkg/dbmate/migration.go
@@ -53,7 +53,7 @@ var (
 
 // Error codes
 var (
-	ErrParseMissingUp      = errors.New("dbmate requires each migration to define an up bock with '-- migrate:up'")
+	ErrParseMissingUp      = errors.New("dbmate requires each migration to define an up block with '-- migrate:up'")
 	ErrParseUnexpectedStmt = errors.New("dbmate does not support statements defined outside of the '-- migrate:up' or '-- migrate:down' blocks")
 )
 


Test patch:
diff --git a/pkg/dbmate/migration_test.go b/pkg/dbmate/migration_test.go
index e01d390..a2e4fb0 100644
--- a/pkg/dbmate/migration_test.go
+++ b/pkg/dbmate/migration_test.go
@@ -79,7 +79,7 @@ drop table users;
 
 	_, _, err = parseMigrationContents(migration)
 	require.NotNil(t, err)
-	require.Equal(t, "dbmate requires each migration to define an up bock with '-- migrate:up'", err.Error())
+	require.Equal(t, "dbmate requires each migration to define an up block with '-- migrate:up'", err.Error())
 
 	// It allows leading comments and whitespace preceding the migrate blocks
 	migration = `
@@ -128,5 +128,5 @@ ADD COLUMN status status_type DEFAULT 'active';
 
 	_, _, err = parseMigrationContents(migration)
 	require.NotNil(t, err)
-	require.Equal(t, "dbmate requires each migration to define an up bock with '-- migrate:up'", err.Error())
+	require.Equal(t, "dbmate requires each migration to define an up block with '-- migrate:up'", err.Error())
 }