Skip to content

Commit

Permalink
chore: truncate branch name
Browse files Browse the repository at this point in the history
  • Loading branch information
titenkov committed Dec 7, 2023
1 parent b79fc04 commit 22802ea
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 22802ea

Please sign in to comment.