Skip to content

Commit 4bd717d

Browse files
committed
buildozer: refactor the glob handling to a special case
1 parent 03bf520 commit 4bd717d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

buildozer/buildozer_test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,14 @@ function test_set_config_string() {
19531953
)'
19541954
}
19551955

1956+
function test_set_glob_srcs() {
1957+
run "$no_deps" 'set srcs glob(["*.go"])' '//pkg:edit'
1958+
assert_equals 'go_library(
1959+
name = "edit",
1960+
srcs = glob(["*.go"]),
1961+
)'
1962+
}
1963+
19561964
function test_fix_unused_load() {
19571965
run 'load(":a.bzl", "a")
19581966
# TODO: refactor

edit/buildozer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,10 @@ func getAttrValueExpr(attr string, args []string, env CmdEnvironment) build.Expr
585585
list = append(list, &build.LiteralExpr{Token: i})
586586
}
587587
return &build.ListExpr{List: list}
588-
case IsList(attr) && !(len(args) == 1 && strings.HasPrefix(args[0], "glob(")):
588+
case IsList(attr) && len(args) == 1 && strings.HasPrefix(args[0], "glob("):
589+
// Single-value glob
590+
return &build.Ident{Name: args[0]}
591+
case IsList(attr):
589592
var list []build.Expr
590593
for _, arg := range args {
591594
list = append(list, getStringExpr(arg, env.Pkg))

0 commit comments

Comments
 (0)