From 3e93fc967143d10d9ab7dc4a056c28f4faeccbee Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Tue, 14 Aug 2018 19:17:33 +0100 Subject: [PATCH] Debug logs to test labeler --- org/labeler.ts | 10 ++++++++++ tests/labeler.test.ts | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/org/labeler.ts b/org/labeler.ts index 27b2e92..4f569db 100644 --- a/org/labeler.ts +++ b/org/labeler.ts @@ -15,6 +15,7 @@ export const labeler = wrap( const repo = gh.repository; const issue = gh.issue; const title = issue.title; + console.log(`Incoming issue data: ${JSON.stringify(issue)}`); const titleWords = title.split(" ") as string[]; let labelsToAdd: string[] = []; @@ -55,7 +56,14 @@ export const labeler = wrap( 'which', ]); + + if (titleEndsInQuestionMark() || titleStartsWithAny(questionWords)) { + console.log('discussion related words found label without spaces and colon'); + addLabelIfDoesNotExist('question') + } + if (titleEndsInQuestionMark() || titleStartsWithAny(questionWords)) { + console.log('discussion related words found'); addLabelIfDoesNotExist('type: question or discussion'); } @@ -71,10 +79,12 @@ export const labeler = wrap( ]); if (titleIncludesAny(documentationWords)) { + console.log('documentation related words found'); addLabelIfDoesNotExist('type: documentation'); } if (labelsToAdd.length > 0) { + console.log(`Labels to be added: ${labelsToAdd.join(',')}`); await danger.github.api.issues.addLabels({ owner: repo.owner.login, repo: repo.name, diff --git a/tests/labeler.test.ts b/tests/labeler.test.ts index 16f8f79..5392322 100644 --- a/tests/labeler.test.ts +++ b/tests/labeler.test.ts @@ -34,7 +34,7 @@ describe('a new issue', () => { repo: 'gatsby', owner: 'gatsbyjs', number: 100, - labels: ['type: question or discussion'] + labels: ['question', 'type: question or discussion'] }) }); }); @@ -46,7 +46,7 @@ describe('a new issue', () => { repo: 'gatsby', owner: 'gatsbyjs', number: 100, - labels: ['type: question or discussion'] + labels: ['question', 'type: question or discussion'] }) }); }); @@ -81,4 +81,4 @@ describe('a new issue', () => { expect(dm.danger.github.api.issues.addLabels).not.toBeCalled() }) }); -}); \ No newline at end of file +});