Skip to content

Commit aff6379

Browse files
committed
Factor out some duplicate code
1 parent b5c7a93 commit aff6379

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

src/githubHelper.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ export default class GithubHelper {
220220
******************************** POST METHODS ********************************
221221
******************************************************************************
222222
*/
223+
userIsCreator(author) {
224+
return author &&
225+
((settings.usermap && settings.usermap[author.username] === settings.github.token_owner) ||
226+
(author.username === settings.github.token_owner));
227+
}
223228

224229
/**
225230
* TODO description
@@ -308,14 +313,10 @@ export default class GithubHelper {
308313
*/
309314
async importIssueAndComments(milestones, issue) {
310315

311-
let userIsCreator = issue.author &&
312-
((settings.usermap && settings.usermap[issue.author.username] === settings.github.token_owner) ||
313-
(issue.author.username === settings.github.token_owner));
314-
315316
let props : IssueImport = {
316317
title: issue.title.trim(),
317318
body: await this.convertIssuesAndComments(
318-
issue.description, issue, !userIsCreator || !issue.description),
319+
issue.description, issue, !this.userIsCreator(issue.author) || !issue.description),
319320
created_at: issue.created_at,
320321
updated_at: issue.updated_at,
321322
closed: issue.state === 'closed'
@@ -786,10 +787,7 @@ export default class GithubHelper {
786787

787788
// Failing all else, create an issue with a descriptive title
788789

789-
let userIsCreator = pullRequest.author &&
790-
((settings.usermap && settings.usermap[pullRequest.author.username] === settings.github.token_owner) ||
791-
(pullRequest.author.username === settings.github.token_owner));
792-
790+
793791
let mergeStr =
794792
'_Merges ' +
795793
pullRequest.source_branch +
@@ -799,7 +797,7 @@ export default class GithubHelper {
799797
let bodyConverted = await this.convertIssuesAndComments(
800798
mergeStr + pullRequest.description,
801799
pullRequest,
802-
!userIsCreator || !settings.useIssueImportAPI
800+
!this.userIsCreator(pullRequest.author) || !settings.useIssueImportAPI
803801
);
804802

805803
if (settings.useIssueImportAPI) {

0 commit comments

Comments
 (0)