Skip to content

Commit 1162a63

Browse files
feat: update changelog convert format to include Change Type (#209)
1 parent 55b7b46 commit 1162a63

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Diff for: tools/cli/internal/cli/changelog/convert/slack.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -133,25 +133,25 @@ func orderAttachments(attachments []*Attachment) []*Attachment {
133133
func newAttachmentFromVersion(path *changelog.Path, version *changelog.Version) []*Attachment {
134134
attachments := make([]*Attachment, 0)
135135
for _, change := range version.Changes {
136-
attachments = append(attachments, newAttachmentFromChange(version.Version, path.HTTPMethod, path.URI, change))
136+
attachments = append(attachments, newAttachmentFromChange(version.Version, path.HTTPMethod, path.URI, path.ChangeType, change))
137137
}
138138

139139
return attachments
140140
}
141141

142-
func newAttachmentFromChange(version, method, path string, change *changelog.Change) *Attachment {
142+
func newAttachmentFromChange(version, method, path, changeType string, change *changelog.Change) *Attachment {
143143
return &Attachment{
144-
Text: newAttachmentText(version, method, path, change.Code, change.Description, strconv.FormatBool(change.BackwardCompatible),
144+
Text: newAttachmentText(version, method, path, changeType, change.Code, change.Description,
145145
strconv.FormatBool(change.HideFromChangelog)),
146146
Color: newColorFromBackwardCompatible(change.BackwardCompatible),
147147
AttachmentType: attachmentTypeDefault,
148148
}
149149
}
150150

151-
func newAttachmentText(version, method, path, changeCode, change, backwardCompatible, hiddenFromChangelog string) string {
151+
func newAttachmentText(version, method, path, changeType, changeCode, change, hiddenFromChangelog string) string {
152152
return fmt.Sprintf(
153-
"\n• *Version*: `%s`\n• *Path*: `%s %s`\n• *Hidden from Changelog*: `%s`\n• *Change Code*: `%s`\n*Change*: `%s`\n• *Backward Compatible*: `%s`",
154-
version, method, path, hiddenFromChangelog, changeCode, change, backwardCompatible)
153+
"\n• *Version*: `%s` | *Hidden from Changelog*: `%s`\n• *Path*: `%s %s`\n• *Change Type*: `%s` | *Change Code*: `%s`\n• *Change*: `%s`",
154+
version, hiddenFromChangelog, method, path, changeType, changeCode, change)
155155
}
156156

157157
func newColorFromBackwardCompatible(backwardCompatible bool) string {

Diff for: tools/cli/internal/cli/changelog/convert/slack_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestNewAttachmentText(t *testing.T) {
2828
path string
2929
changeCode string
3030
change string
31-
backwardCompatible string
31+
changeType string
3232
hiddenFromChangelog string
3333
expected string
3434
}{
@@ -39,9 +39,9 @@ func TestNewAttachmentText(t *testing.T) {
3939
path: "/api/atlas/v2/groups/{groupId}/clusters",
4040
changeCode: "response-property-enum-value-added",
4141
change: "added the new DUBLIN_IRL, FRANKFURT_DEU, LONDON_GBR enum values",
42-
backwardCompatible: "true",
42+
changeType: "UPDATE",
4343
hiddenFromChangelog: "false",
44-
expected: "\n• *Version*: `2024-08-05`\n• *Path*: `GET /api/atlas/v2/groups/{groupId}/clusters`\n• *Hidden from Changelog*: `false`\n*Change Code*: `response-property-enum-value-added`\n• *Change*: `added the new DUBLIN_IRL, FRANKFURT_DEU, LONDON_GBR enum values`\n• *Backward Compatible*: `true`", //nolint:lll //Test string
44+
expected: "\n• *Version*: `2024-08-05` | *Hidden from Changelog*: `false`\n• *Path*: `GET /api/atlas/v2/groups/{groupId}/clusters`\n• *Change Type*: `UPDATE` | *Change Code*: `response-property-enum-value-added`\n• *Change*: `added the new DUBLIN_IRL, FRANKFURT_DEU, LONDON_GBR enum values`", //nolint:lll //Test string
4545
},
4646
{
4747
name: "Non-Backward Compatible Change",
@@ -51,14 +51,14 @@ func TestNewAttachmentText(t *testing.T) {
5151
changeCode: "new-optional-request-property",
5252
change: "added the new optional request property replicaSetScalingStrategy",
5353
hiddenFromChangelog: "true",
54-
backwardCompatible: "false",
55-
expected: "\n• *Version*: `2024-08-05`\n• *Path*: `POST /api/atlas/v2/groups/{groupId}/clusters`\n• *Hidden from Changelog*: `true`\n*Change Code*: `new-optional-request-property`\n• *Change*: `added the new optional request property replicaSetScalingStrategy`\n• *Backward Compatible*: `false`", //nolint:lll //Test string
54+
changeType: "RELEASE",
55+
expected: "\n• *Version*: `2024-08-05` | *Hidden from Changelog*: `true`\n• *Path*: `POST /api/atlas/v2/groups/{groupId}/clusters`\n• *Change Type*: `RELEASE` | *Change Code*: `new-optional-request-property`\n• *Change*: `added the new optional request property replicaSetScalingStrategy`", //nolint:lll //Test string
5656
},
5757
}
5858

5959
for _, tt := range tests {
6060
t.Run(tt.name, func(t *testing.T) {
61-
actual := newAttachmentText(tt.version, tt.method, tt.path, tt.changeCode, tt.change, tt.backwardCompatible, tt.hiddenFromChangelog)
61+
actual := newAttachmentText(tt.version, tt.method, tt.path, tt.changeType, tt.changeCode, tt.change, tt.hiddenFromChangelog)
6262
assert.Equal(t, tt.expected, actual)
6363
})
6464
}

0 commit comments

Comments
 (0)