-
Notifications
You must be signed in to change notification settings - Fork 14
CLOUDP-279336: Avoid that squashing overrides hideFromChangelog #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,27 +112,40 @@ func newSquashHandlers() []handler { | |
} | ||
|
||
// EntryMappings groups entries by ID and then by OperationID and returns a Map[changeCode, Map[operationId, List[oasdiffEntry]]] | ||
func newEntriesMapPerIDAndOperationID(entries []*OasDiffEntry) map[string]map[string][]*OasDiffEntry { | ||
result := make(map[string]map[string][]*OasDiffEntry) | ||
func newEntriesMapPerIDAndOperationID(entries []*OasDiffEntry) (result, hiddenResult map[string]map[string][]*OasDiffEntry) { | ||
result = make(map[string]map[string][]*OasDiffEntry) | ||
hiddenResult = make(map[string]map[string][]*OasDiffEntry) | ||
|
||
for _, entry := range entries { | ||
code := entry.ID | ||
operationID := entry.OperationID | ||
hidden := entry.HideFromChangelog | ||
|
||
// Ensure the code map exists | ||
if _, exists := result[code]; !exists { | ||
result[code] = make(map[string][]*OasDiffEntry) | ||
} | ||
|
||
if _, exists := hiddenResult[code]; !exists { | ||
hiddenResult[code] = make(map[string][]*OasDiffEntry) | ||
} | ||
|
||
|
||
if hidden { | ||
// Append the entry to the appropriate operationID slice | ||
hiddenResult[code][operationID] = append(hiddenResult[code][operationID], entry) | ||
continue | ||
} | ||
|
||
// Append the entry to the appropriate operationID slice | ||
result[code][operationID] = append(result[code][operationID], entry) | ||
} | ||
|
||
return result | ||
return result, hiddenResult | ||
} | ||
|
||
func squashEntries(entries []*OasDiffEntry) ([]*OasDiffEntry, error) { | ||
entriesMap := newEntriesMapPerIDAndOperationID(entries) | ||
entriesByIDandOperationID, hiddenEntriesByIDandOperationID := newEntriesMapPerIDAndOperationID(entries) | ||
|
||
squashHandlers := newSquashHandlers() | ||
squashedEntries := []*OasDiffEntry{} | ||
|
||
|
@@ -145,6 +158,24 @@ func squashEntries(entries []*OasDiffEntry) ([]*OasDiffEntry, error) { | |
} | ||
} | ||
|
||
squashedEntriesNotHidden, err := appplySquashHandlerToMap(squashHandlers, entriesByIDandOperationID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
squashedEntriesHidden, err := appplySquashHandlerToMap(squashHandlers, hiddenEntriesByIDandOperationID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
squashedEntries = append(squashedEntries, squashedEntriesNotHidden...) | ||
squashedEntries = append(squashedEntries, squashedEntriesHidden...) | ||
andreaangiolillo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return squashedEntries, nil | ||
} | ||
|
||
func appplySquashHandlerToMap(squashHandlers []handler, entriesMap map[string]map[string][]*OasDiffEntry) ([]*OasDiffEntry, error) { | ||
squashedEntries := []*OasDiffEntry{} | ||
for _, handler := range squashHandlers { | ||
entryMapPerOperationID, ok := entriesMap[handler.id] | ||
if !ok { | ||
|
@@ -158,7 +189,6 @@ func squashEntries(entries []*OasDiffEntry) ([]*OasDiffEntry, error) { | |
|
||
squashedEntries = append(squashedEntries, sortEntriesByDescription(entries)...) | ||
} | ||
|
||
return squashedEntries, nil | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you update the function comment to include the new returned map?