From 09bb8d742c54633cf709a8643e9099f0b9aa7064 Mon Sep 17 00:00:00 2001 From: Dale Morgan Date: Fri, 26 Jun 2026 14:52:57 +0100 Subject: [PATCH] Support Slack Names with hyphens Currently the the delimiters causes a split on a hyphenated name: ``` name.gsub( /\d+/,"").split(Regexp.union(delimiters)) => ["Cherice", "Sackey-", "Nelson"] ``` This results in `@cherice.sackey-.nelson`, while we want `@cherice.sackey-nelson`. I messed around with the Regex and couldn't get a nice (or robust) solution, so going with the easier option for now. --- .../notifier/deployment_status_message.rb | 1 + .../deployment_status_message_test.rb | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/lib/serverless-tools/notifier/deployment_status_message.rb b/lib/serverless-tools/notifier/deployment_status_message.rb index c88291d8..682b2fd7 100644 --- a/lib/serverless-tools/notifier/deployment_status_message.rb +++ b/lib/serverless-tools/notifier/deployment_status_message.rb @@ -66,6 +66,7 @@ def workflow_run_markdown .split(Regexp.union(delimiters)) .map(&:downcase) .join(".") + .gsub("-.", "-") .delete("'") "<#{run_url}|#{@repo_name}/#{head_branch} ##{run_number}> for @#{slack_name}" diff --git a/test/notifier/deployment_status_message_test.rb b/test/notifier/deployment_status_message_test.rb index 32fe7544..51fbe406 100644 --- a/test/notifier/deployment_status_message_test.rb +++ b/test/notifier/deployment_status_message_test.rb @@ -170,6 +170,43 @@ module ServerlessTools::Notifier assert_equal(subject.text_for_status("start"), expected) end end + + describe "when author name includes a hyphen" do + let(:deploy_info) do + " " \ + "for @cherice.sackey-nelson\n" \ + "⚙️ " \ + "Commit message ()" + end + + before do + mock_git_client + .expects(:workflow_run).with(repo_name, run_id) + .returns({ + "html_url" => "https://github.com/fac/repo-name/actions/runs/3534407323", + "run_attempt" => 1, + "run_number" => 643, + "head_branch" => "branch-name", + "pull_requests" => [], + "head_commit" => { + "id" => sha, + "message" => "Commit message (#182)", + "author" => { + "name" => "Cherice Sackey-Nelson" + } + }, + "repository" => { + "html_url" => "https://github.com/fac/repo-name" + } + }) + end + + it "formats the name correctly for Slack" do + expected = "🏗️ *DEPLOYING* #{deploy_info}" + + assert_equal(subject.text_for_status("start"), expected) + end + end end end end