Skip to content

Commit 979d54c

Browse files
authored
chore(internal/postprocessor): address logic inversion (googleapis#12595)
In googleapis#12541 the config for modules to skip was transitioned from being hardcoded into the implementation to a config file. In the course of that refactor the detect logic was inverted, so instead of a skiplist the new config mechanism acted as an allowlist. This PR corrects that issue, and adds another test to assert the property that skip paths don't appear in the detected module list. To fully address this issue, we'll also need to bump the owlbot lock once this PR is submitted.
1 parent 726eb95 commit 979d54c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

internal/postprocessor/main_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,27 @@ func TestUpdateManifestFile(t *testing.T) {
190190
t.Errorf("updateConfigFile() mismatch (-want +got):\n%s", diff)
191191
}
192192
}
193+
194+
func TestDetectModules(t *testing.T) {
195+
p := &postProcessor{
196+
googleapisDir: googleapisDir,
197+
googleCloudDir: "../..",
198+
}
199+
p.loadConfig()
200+
mods, err := detectModules(p.googleCloudDir, p.config.SkipModuleScanPaths)
201+
if err != nil {
202+
t.Fatalf("detectModules: %v", err)
203+
}
204+
205+
// Assert that none of the detected modules are present in the SkipModuleScanPaths
206+
foundMap := make(map[string]bool)
207+
for _, m := range mods {
208+
foundMap[m] = true
209+
}
210+
for _, sk := range p.config.SkipModuleScanPaths {
211+
if foundMap[sk] {
212+
t.Errorf("detected module %q but it was present in the SkipModuleScanPaths", sk)
213+
}
214+
}
215+
216+
}

internal/postprocessor/releaseplease.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func detectModules(dir string, skipPaths []string) ([]string, error) {
129129
if err != nil {
130130
log.Fatal(err)
131131
}
132-
if !d.IsDir() && d.Name() == "go.mod" && !strings.Contains(path, "internal") && skipMap[filepath.Dir(path)] {
132+
if !d.IsDir() && d.Name() == "go.mod" && !strings.Contains(path, "internal") && !skipMap[filepath.Dir(path)] {
133133
mods = append(mods, filepath.Dir(path))
134134
}
135135
return nil

0 commit comments

Comments
 (0)