Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/librarian/java/postprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,3 +535,13 @@ func createOrVerifyOwlbotPy(outDir string) (err error) {
}
return nil
}

// ToKeepSet normalizes a list of keep paths into a lookup map.
func ToKeepSet(keep []string) map[string]bool {
keepSet := make(map[string]bool, len(keep))
for _, k := range keep {
normalized := strings.TrimSuffix(filepath.ToSlash(k), "/")
keepSet[normalized] = true
}
return keepSet
}
Comment thread
yangyzs marked this conversation as resolved.
Resolved
15 changes: 15 additions & 0 deletions internal/librarian/java/postprocess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1139,3 +1139,18 @@ func TestCreateOrVerifyOwlbotPy_Error(t *testing.T) {
t.Errorf("error = %v, wantErr %v", err, fs.ErrPermission)
}
}

func TestToKeepSet(t *testing.T) {
t.Parallel()
input := []string{"foo/", "bar/baz", "qux/", ""}
got := ToKeepSet(input)
want := map[string]bool{
"foo": true,
"bar/baz": true,
"qux": true,
"": true,
}
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("mismatch (-want +got):\n%s", diff)
}
}
Comment thread
yangyzs marked this conversation as resolved.
Resolved
Loading