Skip to content

Commit

Permalink
Add SQLx query files as generated (#6748)
Browse files Browse the repository at this point in the history
* feat: add sqlx query files as generated

* fix: regex should be query- not queries-

* fix: regex should match exactly .sqlx
  • Loading branch information
mercxry authored Mar 12, 2024
1 parent 943449c commit ca188d5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/linguist/generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def generated?
generated_haxe? ||
generated_jooq? ||
generated_pascal_tlb? ||
generated_sorbet_rbi?
generated_sorbet_rbi? ||
generated_sqlx_query?
end

# Internal: Is the blob an Xcode file?
Expand Down Expand Up @@ -825,5 +826,18 @@ def extract_html_meta(match)
[key, val]
end.select { |x| x.length == 2 }.to_h
end

# Internal: Is this a generated SQLx query file?
#
# SQLx is a Rust SQL library which generates `**/.sqlx/query-*.json` files
# in offline mode (enabled by default).
#
# These are used to be able to compile a project without requiring
# the development database to be online.
#
# Returns true or false.
def generated_sqlx_query?
!!name.match(/(?:^|.*\/)\.sqlx\/query-.+\.json$/)
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/test_blob.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ def test_generated
assert sample_blob_memory("Ruby/rails@7.0.3.1.rbi").generated?
assert sample_blob_memory("Ruby/rendering.rbi").generated?
assert sample_blob_memory("Ruby/actionmailer.rbi").generated?

# SQLx query files
assert fixture_blob_memory("Rust/.sqlx/query-2b8b1aae3740a05cb7179be9c7d5af30e8362c3cba0b07bc18fa32ff1a2232cc.json").generated?
end

def test_vendored
Expand Down

0 comments on commit ca188d5

Please sign in to comment.