Skip to content

Commit

Permalink
Omit commit message descriptions (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
namoscato authored Sep 30, 2022
1 parent 4f81e03 commit ba800ae
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
10 changes: 8 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/__tests__/message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ describe('postMessage', () => {
github.context.sha = '05b16c3beb3a07dceaf6cf964d0be9eccbc026e8'
github.context.payload = {
head_commit: {
message: 'COMMIT-MESSAGE',
message:
'COMMIT-MESSAGE\n\nCo-authored-by: Nick <[email protected]>',
url: 'github.com/commit'
},
sender: {
Expand Down
11 changes: 9 additions & 2 deletions src/github/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function getEventLink(): Link {
const pullRequest = context.payload.pull_request

return {
text: `${pullRequest.title} (#${pullRequest.number})`,
text: getEventLinkText(`${pullRequest.title} (#${pullRequest.number})`),
url: pullRequest.html_url
}
}
Expand All @@ -85,7 +85,7 @@ function getEventLink(): Link {
const commit = context.payload.head_commit

return {
text: commit.message,
text: getEventLinkText(commit.message),
url: commit.url
}
}
Expand All @@ -94,3 +94,10 @@ function getEventLink(): Link {
`Unsupported event ${context.eventName} (currently supported events include: pull_request, push)`
)
}

/**
* Return the first `message` line, i.e. omitting the commit description.
*/
function getEventLinkText(message: string): string {
return message.split('\n', 1)[0]
}

0 comments on commit ba800ae

Please sign in to comment.