Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Debug logs to test labeler #24

Merged
merged 1 commit into from
Aug 16, 2018
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
10 changes: 10 additions & 0 deletions org/labeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
Expand Down Expand Up @@ -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');
}

Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions tests/labeler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
})
});
});
Expand All @@ -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']
})
});
});
Expand Down Expand Up @@ -81,4 +81,4 @@ describe('a new issue', () => {
expect(dm.danger.github.api.issues.addLabels).not.toBeCalled()
})
});
});
});