Merge "ShouldKeepExistingBuldFileForDir look up by dir"
This commit is contained in:
committed by
Gerrit Code Review
commit
1ad62c7073
@@ -341,16 +341,19 @@ func (a Bp2BuildConversionAllowlist) ShouldKeepExistingBuildFileForDir(dir strin
|
|||||||
// Exact dir match
|
// Exact dir match
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
var i int
|
||||||
// Check if subtree match
|
// Check if subtree match
|
||||||
for prefix, recursive := range a.keepExistingBuildFile {
|
for {
|
||||||
if recursive {
|
j := strings.Index(dir[i:], "/")
|
||||||
if strings.HasPrefix(dir, prefix+"/") {
|
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
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Default
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var bp2BuildAllowListKey = NewOnceKey("Bp2BuildAllowlist")
|
var bp2BuildAllowListKey = NewOnceKey("Bp2BuildAllowlist")
|
||||||
|
Reference in New Issue
Block a user