Merge "ShouldKeepExistingBuldFileForDir look up by dir"

This commit is contained in:
Usta (Tsering) Shrestha
2022-11-19 03:55:46 +00:00
committed by Gerrit Code Review

View File

@@ -341,16 +341,19 @@ func (a Bp2BuildConversionAllowlist) ShouldKeepExistingBuildFileForDir(dir strin
// Exact dir match
return true
}
var i int
// Check if subtree match
for prefix, recursive := range a.keepExistingBuildFile {
if recursive {
if strings.HasPrefix(dir, prefix+"/") {
return true
}
for {
j := strings.Index(dir[i:], "/")
if j == -1 {
return false //default
}
prefix := dir[0 : i+j]
i = i + j + 1 // skip the "/"
if recursive, ok := a.keepExistingBuildFile[prefix]; ok && recursive {
return true
}
}
// Default
return false
}
var bp2BuildAllowListKey = NewOnceKey("Bp2BuildAllowlist")