Skip to content
This repository was archived by the owner on May 23, 2025. It is now read-only.

Commit ffdc8fd

Browse files
authored
Merge pull request #124 from johnsanthosh/jsanthosh-support-username-suffix
Support for username suffixes.
2 parents 680fb3b + eb2e250 commit ffdc8fd

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@ JIRA_PASSWORD=
5050

5151
# Optional message to greet your new contributors
5252
#WELCOME_MESSAGE="Hey there, thanks for contributing to the project!"
53+
54+
# Optional variable if defined, appends a suffix to the username pulled out from the email address, before checking if the user is a collaborator in the repo.
55+
#GITHUB_USER_SUFFIX="someusernamesuffix"

plugins/reviewers/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export default class ReviewerPlugin extends BasePlugin {
216216
}
217217
const matches = REVIEWER_REGEX.exec(testSubject);
218218
if (!matches) return testSubject;
219-
return matches[1];
219+
return `${matches[1]}${process.env.GITHUB_USER_SUFFIX || ''}`;
220220
}).filter(r => {
221221
if (!r) return false;
222222
return r !== context.payload.pull_request.user.login;

test/unit/plugins/reviewers.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const reviewersPlugin = new ReviewersPlugin();
2020
describe('ReviewersPlugin', function () {
2121
afterEach(function () {
2222
sandbox.restore();
23+
delete process.env.GITHUB_USER_SUFFIX;
2324
});
2425

2526
let mockContext;
@@ -477,5 +478,39 @@ describe('ReviewersPlugin', function () {
477478
'hobjectson'
478479
]);
479480
});
481+
482+
it('properly gets filtered users with suffix from the reviewers list if GITHUB_USER_SUFFIX is set.', async function () {
483+
process.env.GITHUB_USER_SUFFIX = '-coolsuffix';
484+
userExistsStub.resolves({ status: 204 });
485+
userExistsStub
486+
.withArgs(
487+
sinon.match({
488+
username: 'Bob McNoEmail',
489+
})
490+
)
491+
.resolves({ status: 404 });
492+
// @ts-ignore
493+
const users = await reviewersPlugin.getUsersFromReviewersList(
494+
mockContext,
495+
[
496+
'Joe Schmoe <jschmoe@test.com>',
497+
'John Doe <jdoe@test.com>',
498+
'Bob McNoEmail',
499+
{
500+
name: 'Hans Objectson',
501+
email: 'hobjectson@test.com',
502+
},
503+
{
504+
name: 'Billy ObjectNoEmailHeimer',
505+
},
506+
12345
507+
]
508+
);
509+
assume(users).eqls([
510+
'jschmoe-coolsuffix',
511+
'jdoe-coolsuffix',
512+
'hobjectson-coolsuffix'
513+
]);
514+
});
480515
});
481516
});

0 commit comments

Comments
 (0)