-
Notifications
You must be signed in to change notification settings - Fork 69
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
Reassign PRs back to the author if they haven't filled in the PR description at the time of opening it. #326
Comments
hey @seanlip, I am willing to work on this issue, please assign me this issue. |
@lalitkumawat1m Per the guidance at https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#choosing-a-good-first-issue, please provide an explanation of what your PR will do (with names of files you're changing, what you plan to change in each file, etc.). If it looks good, we can assign you to this issue. Please also follow the other instructions on that wiki page if you have not yet done so. Thanks! |
Hello, @seanlip I am interested in solving this issue please assign it to me. |
@Flying-Pegasus Per the guidance at https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#choosing-a-good-first-issue, please provide an explanation of what your PR will do (with names of files you're changing, what you plan to change in each file, etc.), as well as a video showing that the changes work correctly on your local machine. If it looks good, we can assign you to this issue. Please also follow the other instructions on that wiki page if you have not yet done so. Thanks! |
Proposed Changes
Changes in const checkTemplate = async (pullRequestBody) => {
const missingSections = [];
// Check for "Overview" section
if (!pullRequestBody.includes('### Overview')) {
missingSections.push('Overview');
}
// Check for "Checklist" section
if (!pullRequestBody.includes('### Checklist')) {
missingSections.push('Checklist');
}
// Check for "Proof of Changes" section
if (!pullRequestBody.includes('### Proof of changes')) {
missingSections.push('Proof of Changes');
}
return missingSections;
}
module.exports = {
checkTemplate,
};
Changes in const { checkTemplate } = require('./checkPullRequestTemplate');
robot.on('pull_request.opened', async (context) => {
const prBody = context.payload.pull_request.body;
const missingSections = checkTemplate(prBody);
if (missingSections.length > 0) {
const commentBody = `Hi @${context.payload.pull_request.user.login}, please complete the following sections in your PR description:\n` +
missingSections.map(section => `- ${section}`).join('\n') +
`\n\nThank you!`;
// Post a comment with the missing sections
await context.github.issues.createComment(context.issue({ body: commentBody }));
// Assign the PR back to the author
await context.github.issues.addAssignees(context.issue({
assignees: [context.payload.pull_request.user.login],
}));
}
});
Changes in const { checkTemplate } = require('../checkPullRequestTemplate');
describe('checkTemplate', () => {
it('should return missing sections for an incomplete PR body', () => {
const prBody = '### Overview\nSome text\n\n### Proof of changes\nSome changes';
const missingSections = checkTemplate(prBody);
expect(missingSections).toEqual(['Checklist']);
});
it('should return no missing sections for a complete PR body', () => {
const prBody = '### Overview\nSome text\n\n### Checklist\n- [x] Task 1\n\n### Proof of changes\nSome changes';
const missingSections = checkTemplate(prBody);
expect(missingSections).toHaveLength(0);
});
it('should return all sections if the PR body is empty', () => {
const prBody = '';
const missingSections = checkTemplate(prBody);
expect(missingSections).toEqual(['Overview', 'Checklist', 'Proof of Changes']);
});
}); Changes1. `checkPullRequestTemplate.js`: Update the checkTemplate function to validate all required sections. 2. `index.js`: Use the updated checkTemplate function to handle incomplete PRs, post comments, and reassign them to the author. 3. `checkPullRequestTemplateSpec.js`: Add unit tests to ensure the checkTemplate function works as expected with different PR body inputs. |
Thanks @Flying-Pegasus, I need to see a video demo of this working (see my previous comment). See oppia/stale-review-request-notifier#4 (comment) for an example -- thanks! |
Is your feature request related to a problem? Please describe.
Sometimes PRs are opened without an adequate description. This makes it hard for reviewers to review the PR.
Describe the solution you'd like
Oppiabot should reassign the PR back to the author if the PR description is not filled in. (It's fine to use #N/A for point 1 if there's no issue number, but point 2 should always be fully filled in.)
The text was updated successfully, but these errors were encountered: