Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions dist/813.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/813.index.js.map

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

8 changes: 3 additions & 5 deletions src/helpers/create-batched-commit-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ export const createBatchedCommitMessage = () => {
return eventPayload.commits
.map(commit => {
const prNumberWithParens = commit.message.match(/\(#(\d+)\)/)?.[0] ?? '';
const messageWithoutPrNumber = commit.message.replace(prNumberWithParens, '').trim();
const messageWithoutPrNumber = commit.message.replace(prNumberWithParens, '').split('\n')[0]?.trim() ?? '';
const truncatedMessage = messageWithoutPrNumber.slice(0, maxCharactersPerMessage);
if (truncatedMessage.length < messageWithoutPrNumber.length) {
return `${truncatedMessage}... ${prNumberWithParens ?? 'PR unknown'}`;
}
return commit.message;
const ellipses = truncatedMessage.length < messageWithoutPrNumber.length ? '...' : '';
return `${truncatedMessage}${ellipses} ${prNumberWithParens}`;
})
.join(' and ');
};
23 changes: 22 additions & 1 deletion test/helpers/create-batched-commit-message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('createBatchedCommitMessage', () => {
});
});

describe('createBatchedCommitMessage', () => {
describe('createBatchedCommitMessage long messages', () => {
beforeEach(() => {
context.payload.commits = [
{
Expand All @@ -62,3 +62,24 @@ describe('createBatchedCommitMessage', () => {
);
});
});

describe('createBatchedCommitMessage multiline messages', () => {
beforeEach(() => {
context.payload.commits = [
{
id: '1234567890abcdef',
message: 'Fix a really really long issue \n' + ' \n' + ' * fix the issue\n' + ' \n' + ' * definitely fix the issue (#1)',
author: { name: 'John Doe', email: '' }
},
{
id: '1234567891abcdef',
message: 'Fix another really really long issue \n' + ' \n' + ' * fix the issue\n' + ' \n' + ' * definitely fix the issue (#2)',
author: { name: 'Jane Doe', email: '' }
}
];
});
it('should truncate the message', () => {
const result = createBatchedCommitMessage();
expect(result).toBe('Fix a really really long issue (#1) and Fix another really really long issue (#2)');
});
});