Skip to content

Commit 56dee38

Browse files
neilkimmettmacklinu
authored andcommitted
fix: only add one example JIRA key to warning (#47)
1 parent 17459d5 commit 56dee38

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/index.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ describe('jiraIssue()', () => {
2929
'Please add the JIRA issue key to the PR title (e.g. ABC-123)'
3030
)
3131
})
32+
it('only adds one example key to warning', () => {
33+
global.danger = { github: { pr: { title: 'Change some things' } } }
34+
jiraIssue({
35+
key: ['ABC', 'DEF'],
36+
url: 'https://jira.net/browse',
37+
})
38+
expect(global.warn).toHaveBeenCalledWith(
39+
'Please add the JIRA issue key to the PR title (e.g. ABC-123)'
40+
)
41+
})
3242
it('adds the JIRA issue link to the messages table', () => {
3343
global.danger = {
3444
github: { pr: { title: '[ABC-808] Change some things' } },

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ export default function jiraIssue(options: Options) {
9595
message(`${emoji} ${jiraUrls.join(', ')}`)
9696
}
9797
} else {
98+
const firstKey = Array.isArray(key) ? key[0] : key
9899
warn(
99-
`Please add the JIRA issue key to the PR ${location} (e.g. ${key}-123)`
100+
`Please add the JIRA issue key to the PR ${location} (e.g. ${firstKey}-123)`
100101
)
101102
}
102103
}

0 commit comments

Comments
 (0)