Add an error check in bazelPackage for malformed labels.

Bug: 204281595
Test: CI
Change-Id: Ia94a0b5c8dd3a0294475e9bc816a19ae03f7342d
This commit is contained in:
Jingwen Chen
2021-11-02 06:23:07 +00:00
parent 8528f4ec5e
commit 80b6b64db5

View File

@@ -370,11 +370,17 @@ func BazelModuleLabel(ctx TopDownMutatorContext, module blueprint.Module) string
func bazelShortLabel(label string) string {
i := strings.Index(label, ":")
if i == -1 {
panic(fmt.Errorf("Could not find the ':' character in '%s', expected a fully qualified label.", label))
}
return label[i:]
}
func bazelPackage(label string) string {
i := strings.Index(label, ":")
if i == -1 {
panic(fmt.Errorf("Could not find the ':' character in '%s', expected a fully qualified label.", label))
}
return label[0:i]
}