Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a welcome comment to first time contributor PRs #28118

Merged
merged 5 commits into from
Feb 8, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ async function firstTimeContributorLabel( payload, octokit ) {
issue_number: payload.pull_request.number,
labels: [ 'First-time Contributor' ],
} );

/**
* Adds a welcome comment to the first time PR
*/

await octokit.issues.createComment( {
owner,
repo,
issue_number: payload.pull_request.number,
body:
':wave: Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @' +
author +
"!. In case you missed it, we'd love to have you join us in our [Slack community](https://make.wordpress.org/chat/)," +
'where we hold [regularly weekly meetings](https://make.wordpress.org/core/tag/core-editor-summary/) open to anyone to coordinate with each other.\n\n' +
'If you want to learn more about WordPress development in general, check out the [Core Handbook](https://make.wordpress.org/core/handbook/) full of helpful information.',
} );
}
annezazu marked this conversation as resolved.
Show resolved Hide resolved

module.exports = firstTimeContributorLabel;
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe( 'firstTimeContributorLabel', () => {
},
issues: {
addLabels: jest.fn(),
createComment: jest.fn(),
},
};

Expand All @@ -43,6 +44,7 @@ describe( 'firstTimeContributorLabel', () => {
author: 'ghost',
} );
expect( octokit.issues.addLabels ).not.toHaveBeenCalled();
expect( octokit.issues.createComment ).not.toHaveBeenCalled();
} );

it( 'adds the First Time Contributor label if the user has no commits', async () => {
Expand All @@ -56,9 +58,16 @@ describe( 'firstTimeContributorLabel', () => {
},
issues: {
addLabels: jest.fn(),
createComment: jest.fn(),
},
};

const expectedComment =
':wave: Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @ghost' +
"!. In case you missed it, we'd love to have you join us in our [Slack community](https://make.wordpress.org/chat/)," +
'where we hold [regularly weekly meetings](https://make.wordpress.org/core/tag/core-editor-summary/) open to anyone to coordinate with each other.\n\n' +
'If you want to learn more about WordPress development in general, check out the [Core Handbook](https://make.wordpress.org/core/handbook/) full of helpful information.';

await firstTimeContributorLabel( payload, octokit );

expect( octokit.repos.listCommits ).toHaveBeenCalledWith( {
Expand All @@ -72,5 +81,11 @@ describe( 'firstTimeContributorLabel', () => {
issue_number: 123,
labels: [ 'First-time Contributor' ],
} );
expect( octokit.issues.createComment ).toHaveBeenCalledWith( {
owner: 'WordPress',
repo: 'gutenberg',
issue_number: 123,
body: expectedComment,
} );
} );
} );