Skip to content

Commit e0cd833

Browse files
authored
[sc-53104] Fix PR number parsing for multi-line commit messages (#146)
1 parent 2271a91 commit e0cd833

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__tests__/getMessageAuthor.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,22 @@ describe('getMessageAuthor', () => {
277277
})
278278
})
279279

280+
describe('when the head commit message is multiple lines', () => {
281+
beforeEach(() => {
282+
github.context.payload.head_commit.message =
283+
'My new Feature (#8987)\n' +
284+
' \n' +
285+
' Co-authored-by: Some Body <[email protected]>'
286+
})
287+
288+
it('does not fallback on the merge queue user', async () => {
289+
expect(await getMessageAuthor(octokit, slack)).toStrictEqual({
290+
username: 'mdavis',
291+
icon_url: 'github.com/mdavis'
292+
})
293+
})
294+
})
295+
280296
describe('when the request for PR info fails/does not include required info', () => {
281297
beforeEach(() => {
282298
;(octokit.rest.pulls.get as unknown as jest.Mock).mockImplementation(

src/getMessageAuthor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async function getPullRequestMergerFromPushCommit(
126126
throw new Error('Unexpected push event payload (undefined head_commit).')
127127
}
128128

129-
const matches = commit.message.match(/\(#(\d+)\)$/)
129+
const matches = commit.message.match(/\(#(\d+)\)$/m)
130130

131131
if (!matches) {
132132
throw new Error(

0 commit comments

Comments
 (0)