`please format` does not canonicalise local build labels
The please format command helpfully canonicalises and deduplicates build labels. For example the following BUILD file:
go_library(
name = "name",
srcs = [
"src.go",
],
deps = [
"//path/to/my/package:package",
"//path/to/my/package:package",
"//path/to/my/package",
"//path/to/my/package",
],
)
is formatted as:
go_library(
name = "name",
srcs = [
"src.go",
],
deps = ["//path/to/my/package"],
)
However, the same is not true for local build labels.
For example the following BUILD file:
# path/to/my/package/BUILD
go_library(
name = "name",
srcs = [
"src.go",
],
deps = [
"//path/to/my/package:package",
"//path/to/my/package:package",
"//path/to/my/package",
"//path/to/my/package",
":package",
":package",
],
)
is formatted as:
go_library(
name = "name",
srcs = [
"src.go",
],
deps = [
":package",
"//path/to/my/package",
],
)
I think it would be preferable if it was formatted as:
go_library(
name = "name",
srcs = [
"src.go",
],
deps = [
":package",
],
)
This would ensure that the target is not duplicated and would ensure that there is a single canonical label. If there is consensus that this is preferable, I'd be happy to raise a PR - thanks.
Yes, I agree that what you suggest would be preferable, and we'd be delighted to receive a PR from you!
I've added https://github.com/please-build/buildtools/pull/10 which should solve this