Apply module scope to file validation checks
This commit is contained in:
@@ -12,9 +12,8 @@ func checkFileSize(tree *CandidateTree, settings *FileSizeSettings) error {
|
||||
if settings.LimitBytes != nil {
|
||||
limit = *settings.LimitBytes
|
||||
}
|
||||
exclusions := normalizedExclusions(settings.Exclusions)
|
||||
for _, entry := range tree.Entries() {
|
||||
if entry.Type != "blob" || !entry.HasSize || excludedByPath(entry.Path, exclusions) {
|
||||
for _, entry := range tree.inputEntries {
|
||||
if entry.Type != "blob" || !entry.HasSize || excludedByPath(entry.Path, settings.Exclusions) {
|
||||
continue
|
||||
}
|
||||
if entry.Size > limit {
|
||||
@@ -31,6 +30,23 @@ func checkFileSize(tree *CandidateTree, settings *FileSizeSettings) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func fileSizeSettingsForModule(settings *FileSizeSettings, modulePath string) *FileSizeSettings {
|
||||
if settings == nil {
|
||||
return nil
|
||||
}
|
||||
selected := *settings
|
||||
moduleRelative := make([]string, len(settings.Exclusions))
|
||||
for index, exclusion := range settings.Exclusions {
|
||||
if modulePath == "." || path.IsAbs(exclusion) || exclusion == "" {
|
||||
moduleRelative[index] = exclusion
|
||||
continue
|
||||
}
|
||||
moduleRelative[index] = modulePath + "/" + exclusion
|
||||
}
|
||||
selected.Exclusions = normalizedExclusions(moduleRelative)
|
||||
return &selected
|
||||
}
|
||||
|
||||
func normalizedExclusions(exclusions []string) []string {
|
||||
result := make([]string, 0, len(exclusions))
|
||||
for _, exclusion := range exclusions {
|
||||
|
||||
Reference in New Issue
Block a user