From 22802eafc2653ac76fe194b95010fc061d2e152b Mon Sep 17 00:00:00 2001 From: Pavel Titenkov Date: Thu, 7 Dec 2023 14:10:02 +0100 Subject: [PATCH] chore: truncate branch name --- index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 058ca31..eb0c800 100644 --- a/index.js +++ b/index.js @@ -126,14 +126,16 @@ try { const newlineIndex = originalCommitMessage.indexOf('\n'); - // Trim commit message to first line + // Truncate commit message to first line let commitMessage = newlineIndex > -1 ? originalCommitMessage.substring(0, newlineIndex) : originalCommitMessage; - // Trim commit message to 50 characters + // Truncate commit message to 50 characters commitMessage = commitMessage.length >= 50 ? commitMessage.substring(0, 50) + '...' : commitMessage + // Truncate branch name to 33 characters + branchName = env.branch.length >= 33 ? env.branch.substring(0, 33) + '...' : env.branch const details = commitMessage - ? `>${commitMessage}\n>${links.commit} | By *${sender.name}* on \`${env.branch}\`` - : `>By *${sender.name}* on \`${env.branch}\`` + ? `>${commitMessage}\n>${links.commit} | By *${sender.name}* on \`${branchName}\`` + : `>By *${sender.name}* on \`${branchName}\`` if (!process.env.SLACK_WEBHOOK_URL) { core.setFailed('Missing SLACK_WEBHOOK_URL environment variable')