fix nil check, make WithPreservedFields accumulate
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user