Skip to content

Sort targets in the buf_breaking rules #100

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

Merged
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
2 changes: 2 additions & 0 deletions gazelle/buf/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package buf

import (
"log"
"sort"

"github.com/bazelbuild/bazel-gazelle/config"
"github.com/bazelbuild/bazel-gazelle/label"
Expand Down Expand Up @@ -88,5 +89,6 @@ func resolveProtoTargetsForRule(
for target := range targetSet {
targets = append(targets, target)
}
sort.Strings(targets)
ruleToResolve.SetAttr("targets", targets)
}
5 changes: 4 additions & 1 deletion gazelle/buf/testdata/breaking_module/BUILD.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ buf_breaking_test(
name = "buf_breaking",
against = "//:against_file",
config = "//:buf.yaml",
targets = ["//foo/v1:foo_proto"],
targets = [
"//bar/v1:bar_proto",
"//foo/v1:foo_proto",
],
)
9 changes: 9 additions & 0 deletions gazelle/buf/testdata/breaking_module/bar/v1/BUILD.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_buf//buf:defs.bzl", "buf_lint_test")

proto_library(
name = "bar_proto",
srcs = ["bar.proto"],
visibility = ["//visibility:public"],
)

14 changes: 14 additions & 0 deletions gazelle/buf/testdata/breaking_module/bar/v1/BUILD.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_buf//buf:defs.bzl", "buf_lint_test")

proto_library(
name = "bar_proto",
srcs = ["bar.proto"],
visibility = ["//visibility:public"],
)

buf_lint_test(
name = "bar_proto_lint",
config = "//:buf.yaml",
targets = [":bar_proto"],
)
Empty file.
5 changes: 4 additions & 1 deletion gazelle/buf/testdata/v2/breaking_module/BUILD.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ buf_breaking_test(
name = "buf_breaking",
against = "//:against_file",
config = "//:buf.yaml",
targets = ["//foo/v1:foo_proto"],
targets = [
"//bar/v1:bar_proto",
"//foo/v1:foo_proto",
],
)
9 changes: 9 additions & 0 deletions gazelle/buf/testdata/v2/breaking_module/bar/v1/BUILD.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_buf//buf:defs.bzl", "buf_lint_test")

proto_library(
name = "bar_proto",
srcs = ["bar.proto"],
visibility = ["//visibility:public"],
)

14 changes: 14 additions & 0 deletions gazelle/buf/testdata/v2/breaking_module/bar/v1/BUILD.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_buf//buf:defs.bzl", "buf_lint_test")

proto_library(
name = "bar_proto",
srcs = ["bar.proto"],
visibility = ["//visibility:public"],
)

buf_lint_test(
name = "bar_proto_lint",
config = "//:buf.yaml",
targets = [":bar_proto"],
)
Empty file.