Skip to content
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
4 changes: 2 additions & 2 deletions .github/actions/javascript/reviewerChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const https = __nccwpck_require__(7211);
const GitHubUtils = __nccwpck_require__(7999);

const pathToReviewerChecklist = 'https://raw.githubusercontent.com/Expensify/App/main/contributingGuides/REVIEWER_CHECKLIST.md';
const reviewerChecklistStartsWith = '## Reviewer Checklist';
const reviewerChecklistContains = '# Reviewer Checklist';
const issue = github.context.payload.issue ? github.context.payload.issue.number : github.context.payload.pull_request.number;
const combinedComments = [];

Expand Down Expand Up @@ -75,7 +75,7 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) {
console.log(`Comment ${i} starts with: ${comment.slice(0, 20)}...`);

// Found the reviewer checklist, so count how many completed checklist items there are
if (comment.startsWith(reviewerChecklistStartsWith)) {
if (comment.indexOf(reviewerChecklistContains) !== -1) {
console.log('Found the reviewer checklist!');
foundReviewerChecklist = true;
numberOfFinishedChecklistItems = (comment.match(/- \[x\]/gi) || []).length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const https = require('https');
const GitHubUtils = require('../../../libs/GithubUtils');

const pathToReviewerChecklist = 'https://raw.githubusercontent.com/Expensify/App/main/contributingGuides/REVIEWER_CHECKLIST.md';
const reviewerChecklistStartsWith = '## Reviewer Checklist';
const reviewerChecklistContains = '# Reviewer Checklist';
const issue = github.context.payload.issue ? github.context.payload.issue.number : github.context.payload.pull_request.number;
const combinedComments = [];

Expand Down Expand Up @@ -65,7 +65,7 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) {
console.log(`Comment ${i} starts with: ${comment.slice(0, 20)}...`);

// Found the reviewer checklist, so count how many completed checklist items there are
if (comment.startsWith(reviewerChecklistStartsWith)) {
if (comment.indexOf(reviewerChecklistContains) !== -1) {

@rushatgabhane rushatgabhane Dec 2, 2022 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB:

Suggested change
if (comment.indexOf(reviewerChecklistContains) !== -1) {
if (comment.toLowerCase().includes(reviewerChecklistContains)) {

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes

@techievivek techievivek Dec 2, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this

const reviewerChecklistPattern = /#{0,6}\s?reviewer checklist\n/gi;

and then

if (reviewerChecklistPattern.test(comment)) {
    // code
}

But then this is not a blocker.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I believe this /#{0,6}\s?reviewer checklist\n/gi; allows even no #, right? I'm a bit concerned about relaxing the check too much and finding the wrong comment. I also think the regex may be overkill for something so simple.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that it seems over-engineered. I will go forward and merge it.

console.log('Found the reviewer checklist!');
foundReviewerChecklist = true;
numberOfFinishedChecklistItems = (comment.match(/- \[x\]/gi) || []).length;
Expand Down