fix nil check, make WithPreservedFields accumulate

This commit is contained in:
kerobbi
2026-02-24 14:59:32 +00:00
parent 67699f0054
commit c29fcb5938
2 changed files with 13 additions and 6 deletions
+7 -2
View File
@@ -698,10 +698,15 @@ func convertToMinimalRelease(release *github.RepositoryRelease) MinimalRelease {
}
func convertToMinimalTag(tag *github.RepositoryTag) MinimalTag {
return MinimalTag{
m := MinimalTag{
Name: tag.GetName(),
SHA: tag.GetCommit().GetSHA(),
}
if commit := tag.GetCommit(); commit != nil {
m.SHA = commit.GetSHA()
}
return m
}
func convertToMinimalReviewThreadsResponse(query reviewThreadsQuery) MinimalReviewThreadsResponse {
+6 -4
View File
@@ -28,12 +28,14 @@ func WithMaxDepth(d int) OptimizeListOption {
}
}
// WithPreservedFields sets keys that are exempt from all destructive strategies except whitespace normalization.
// Keys are matched against post-flatten map keys, so for nested fields like "user.html_url", the dotted key must be
// added explicitly. Empty collections are still dropped. Wins over collectionExtractors.
// WithPreservedFields adds keys that are exempt from all destructive strategies except whitespace normalization.
// Keys are matched against post-flatten map keys, so for nested fields like "user.html_url", the dotted key must
// be added explicitly.
func WithPreservedFields(fields ...string) OptimizeListOption {
return func(c *OptimizeListConfig) {
c.preservedFields = make(map[string]bool, len(fields))
if c.preservedFields == nil {
c.preservedFields = make(map[string]bool, len(fields))
}
for _, f := range fields {
c.preservedFields[f] = true
}