Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for *.MODULE.bazel files #1266

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const (
TypeWorkspace
// TypeBzl represents .bzl files
TypeBzl
//TypeModule represents MODULE.bazel files
//TypeModule represents MODULE.bazel and *.MODULE.bazel files
TypeModule
)

Expand Down Expand Up @@ -130,7 +130,7 @@ func getFileType(filename string) FileType {
if strings.HasSuffix(basename, ".oss") {
basename = basename[:len(basename)-4]
}
if basename == "module.bazel" {
if basename == "module.bazel" || strings.HasSuffix(basename, ".module.bazel") {
return TypeModule
}
ext := filepath.Ext(basename)
Expand Down
30 changes: 30 additions & 0 deletions buildozer/buildozer_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2038,6 +2038,36 @@ EOF
diff -u MODULE.bazel.expected MODULE.bazel || fail "Output didn't match"
}

function test_module_bazel_segment() {
cat > go.MODULE.bazel <<EOF
module(
name = "foo",
version = "0.27.0",
)
bazel_dep(name = "gazelle", version = "0.30.0")
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(go_deps, "com_example_foo")
EOF

cat > go.MODULE.bazel.expected <<EOF
module(
name = "foo",
version = "0.27.0",
)
bazel_dep(name = "gazelle", version = "0.30.0")
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
EOF

$buildozer 'delete' //go.MODULE.bazel:%10
diff -u go.MODULE.bazel.expected go.MODULE.bazel || fail "Output didn't match"
}

function test_module_bazel_new() {
cat > MODULE.bazel <<EOF
bazel_dep(name = "gazelle", version = "0.30.0")
Expand Down