Skip to content

Commit f17cdb8

Browse files
committed
support single quoted strings
1 parent 69b160d commit f17cdb8

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

internal/librariangen/bazel/parser.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,13 @@ func getRegexp(key, pattern string) *regexp.Regexp {
101101
}
102102

103103
func findString(content, name string) string {
104-
re := getRegexp("findString_"+name, fmt.Sprintf(`%s\s*=\s*"([^"]+)"`, name))
105-
if match := re.FindStringSubmatch(content); len(match) > 1 {
106-
return match[1]
104+
re := getRegexp("findString_"+name, fmt.Sprintf(`%s\s*=\s*(?:"([^"]+)"|'([^']+)'){1}`, name))
105+
match := re.FindStringSubmatch(content)
106+
if len(match) > 2 {
107+
if match[1] != "" {
108+
return match[1] // Double-quoted
109+
}
110+
return match[2] // Single-quoted
107111
}
108112
slog.Debug("librariangen: failed to find string attr in BUILD.bazel", "name", name)
109113
return ""

internal/librariangen/bazel/parser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ java_gapic_library(
3838
":asset_java_grpc",
3939
"//google/iam/v1:iam_java_grpc",
4040
],
41-
transport = "grpc+rest",
41+
transport = 'grpc+rest',
4242
deps = [
4343
":asset_java_proto",
4444
"//google/api:api_java_proto",

0 commit comments

Comments
 (0)