Skip to content

Commit

Permalink
Register MODULE.bazel.lock as JSON and generated (#6783)
Browse files Browse the repository at this point in the history
* Recognize Bazel's bzlmod lockfiles (MODULE.bazel.lock)

* Shrink sample MODULE.bazel.lock
  • Loading branch information
dtolnay authored Jun 7, 2024
1 parent efa4ec0 commit 9d2fd70
Show file tree
Hide file tree
Showing 4 changed files with 366 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/linguist/generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def generated?
composer_lock? ||
cargo_lock? ||
flake_lock? ||
bazel_lock? ||
node_modules? ||
go_vendor? ||
go_lock? ||
Expand Down Expand Up @@ -484,6 +485,13 @@ def flake_lock?
!!name.match(/(^|\/)flake\.lock$/)
end

# Internal: Is the blob a Bazel generated bzlmod lockfile?
#
# Returns true or false
def bazel_lock?
!!name.match(/(^|\/)MODULE\.bazel\.lock$/)
end

# Is the blob a VCR Cassette file?
#
# Returns true or false
Expand Down
1 change: 1 addition & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3219,6 +3219,7 @@ JSON:
- ".tern-config"
- ".tern-project"
- ".watchmanconfig"
- MODULE.bazel.lock
- Pipfile.lock
- composer.lock
- deno.lock
Expand Down
354 changes: 354 additions & 0 deletions samples/JSON/filenames/MODULE.bazel.lock

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 @@ -166,6 +166,9 @@ def test_generated
# Nix generated flake.lock file
assert sample_blob_memory("JSON/filenames/flake.lock").generated?

# Bazel generated bzlmod lockfile
assert sample_blob_memory("JSON/filenames/MODULE.bazel.lock").generated?

# pnpm lockfile
assert fixture_blob_memory("YAML/pnpm-lock.yaml").generated?

Expand Down

0 comments on commit 9d2fd70

Please sign in to comment.