Skip to content

Commit

Permalink
fix(slack): add missing scope to Slack message
Browse files Browse the repository at this point in the history
The Slack integration did not reflect the same output as normal publish flow.

Closes #266
  • Loading branch information
fallion committed Oct 24, 2021
1 parent 5664d19 commit 9b6b370
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion internal/slack/release_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ func buildReleaseTitle(remote GitRemoter) slack.Block {
}
}

func addScope(scope string) string {
if scope == "" {
return ""
}
return fmt.Sprintf("*(%s)* ", scope)
}

func buildCommitList(commits []quoad.Commit, remote string) []slack.Block {
builder := strings.Builder{}
blocks := []slack.Block{}
Expand All @@ -118,10 +125,11 @@ func buildCommitList(commits []quoad.Commit, remote string) []slack.Block {

builder.WriteString(
fmt.Sprintf(
"`%s` <%s/commit/%s|*%s*>",
"`%s` <%s/commit/%s|%s%s>",
smallHash,
remote,
smallHash,
addScope(commit.Scope),
commit.Heading,
),
)
Expand Down
2 changes: 1 addition & 1 deletion internal/slack/testdata/expected_output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"blocks":[{"type":"header","text":{"type":"plain_text","text":":tada: New release for some/thing","emoji":true}},{"type":"section","text":{"type":"mrkdwn","text":":rocket: *Features*"}},{"type":"context","elements":[{"type":"mrkdwn","text":"1 commit referencing 0 issues"}]},{"type":"section","text":{"type":"mrkdwn","text":"`00000000` \u003chttps://example.com/some/thing/commit/00000000|*ci test*\u003e\r\n"}},{"type":"divider"},{"type":"section","text":{"type":"mrkdwn","text":":bug: *Bug fixes*"}},{"type":"context","elements":[{"type":"mrkdwn","text":"2 commits referencing 0 issues"}]},{"type":"section","text":{"type":"mrkdwn","text":"`00000000` \u003chttps://example.com/some/thing/commit/00000000|*huge bug*\u003e\r\n`00000000` \u003chttps://example.com/some/thing/commit/00000000|*bug fix*\u003e\r\n"}},{"type":"divider"},{"type":"section","text":{"type":"mrkdwn","text":":wrench: *Chores and Improvements*"}},{"type":"context","elements":[{"type":"mrkdwn","text":"2 commits referencing 3 issues"}]},{"type":"section","text":{"type":"mrkdwn","text":"`00000000` \u003chttps://example.com/some/thing/commit/00000000|*testing*\u003e _ref \u003chttps://example.com/some/thing/issues/1|#1\u003e,\u003chttps://example.com/some/thing/issues/2|#2\u003e_\r\n`00000000` \u003chttps://example.com/some/thing/commit/00000000|*this should end up in chores*\u003e _ref \u003chttps://example.com/some/thing/issues/3|#3\u003e_\r\n"}},{"type":"divider"},{"type":"section","text":{"type":"mrkdwn","text":":package: *Other*"}},{"type":"context","elements":[{"type":"mrkdwn","text":"2 commits referencing 0 issues"}]},{"type":"section","text":{"type":"mrkdwn","text":"`00000000` \u003chttps://example.com/some/thing/commit/00000000|*merge master in something*\u003e\r\n`00000000` \u003chttps://example.com/some/thing/commit/00000000|*random*\u003e\r\n"}},{"type":"divider"}]}
{"blocks":[{"type":"header","text":{"type":"plain_text","text":":tada: New release for some/thing","emoji":true}},{"type":"section","text":{"type":"mrkdwn","text":":rocket: *Features*"}},{"type":"context","elements":[{"type":"mrkdwn","text":"1 commit referencing 0 issues"}]},{"type":"section","text":{"type":"mrkdwn","text":"`00000000` \u003chttps://example.com/some/thing/commit/00000000|*(ci)* ci test\u003e\r\n"}},{"type":"divider"},{"type":"section","text":{"type":"mrkdwn","text":":bug: *Bug fixes*"}},{"type":"context","elements":[{"type":"mrkdwn","text":"2 commits referencing 0 issues"}]},{"type":"section","text":{"type":"mrkdwn","text":"`00000000` \u003chttps://example.com/some/thing/commit/00000000|huge bug\u003e\r\n`00000000` \u003chttps://example.com/some/thing/commit/00000000|bug fix\u003e\r\n"}},{"type":"divider"},{"type":"section","text":{"type":"mrkdwn","text":":wrench: *Chores and Improvements*"}},{"type":"context","elements":[{"type":"mrkdwn","text":"2 commits referencing 3 issues"}]},{"type":"section","text":{"type":"mrkdwn","text":"`00000000` \u003chttps://example.com/some/thing/commit/00000000|testing\u003e _ref \u003chttps://example.com/some/thing/issues/1|#1\u003e,\u003chttps://example.com/some/thing/issues/2|#2\u003e_\r\n`00000000` \u003chttps://example.com/some/thing/commit/00000000|this should end up in chores\u003e _ref \u003chttps://example.com/some/thing/issues/3|#3\u003e_\r\n"}},{"type":"divider"},{"type":"section","text":{"type":"mrkdwn","text":":package: *Other*"}},{"type":"context","elements":[{"type":"mrkdwn","text":"2 commits referencing 0 issues"}]},{"type":"section","text":{"type":"mrkdwn","text":"`00000000` \u003chttps://example.com/some/thing/commit/00000000|merge master in something\u003e\r\n`00000000` \u003chttps://example.com/some/thing/commit/00000000|random\u003e\r\n"}},{"type":"divider"}]}

0 comments on commit 9b6b370

Please sign in to comment.