@@ -11596,6 +11596,28 @@ function isCommentCreatedEvent(payload) {
1159611596function isCommentEditedEvent(payload) {
1159711597 return payload.action === CONST_1.default.ACTIONS.EDITED;
1159811598}
11599+ /**
11600+ * Checks if a comment body matches the criteria for a Proposal.
11601+ */
11602+ function getIsProposal(body) {
11603+ if (!body) {
11604+ return false;
11605+ }
11606+ const lowerCaseBody = body.toLowerCase();
11607+ return body.includes(CONST_1.default.PROPOSAL_KEYWORD) && lowerCaseBody.includes(CONST_1.default.PROPOSAL_HEADER_A) && lowerCaseBody.includes(CONST_1.default.PROPOSAL_HEADER_B);
11608+ }
11609+ /**
11610+ * Determines if a comment author is a known bot or a bot-type account.
11611+ */
11612+ function getIsBotAuthor(user) {
11613+ if (!user) {
11614+ return false;
11615+ }
11616+ const knownBotLogins = [CONST_1.default.COMMENT.NAME_MELVIN_A, CONST_1.default.COMMENT.NAME_MELVIN_B, CONST_1.default.COMMENT.NAME_CODEX, CONST_1.default.COMMENT.NAME_GITHUB_ACTIONS];
11617+ const isBotType = user.type === CONST_1.default.COMMENT.TYPE_BOT;
11618+ const isKnownLogin = knownBotLogins.includes(user.login ?? '');
11619+ return isBotType || isKnownLogin;
11620+ }
1159911621// Main function to process the workflow event
1160011622async function run() {
1160111623 // Capture the timestamp immediately at the start of the run
@@ -11650,22 +11672,22 @@ async function run() {
1165011672 core.endGroup();
1165111673 let didFindDuplicate = false;
1165211674 let originalProposal;
11675+ const isNewCommentAProposal = getIsProposal(newProposalBody);
11676+ if (!isNewCommentAProposal) {
11677+ console.log('New comment is not a proposal. Skipping duplicate check.');
11678+ return;
11679+ }
1165311680 for (const previousProposal of commentsResponse) {
1165411681 const body = previousProposal.body ?? '';
11655- const lowerCaseBody = body.toLowerCase() ?? '';
11656- const isProposal = !!body.includes(CONST_1.default.PROPOSAL_KEYWORD) && !!lowerCaseBody.includes(CONST_1.default.PROPOSAL_HEADER_A) && !!lowerCaseBody.includes(CONST_1.default.PROPOSAL_HEADER_B);
11682+ const isProposal = getIsProposal(body);
1165711683 const previousProposalCreatedAt = new Date(previousProposal.created_at).getTime();
1165811684 // Early continue if not a proposal or previous comment is newer than current one
1165911685 if (!isProposal || previousProposalCreatedAt >= newProposalCreatedAt) {
1166011686 continue;
1166111687 }
11662- const isAuthorBot = previousProposal.user?.login === CONST_1.default.COMMENT.NAME_MELVIN_A ||
11663- previousProposal.user?.login === CONST_1.default.COMMENT.NAME_MELVIN_B ||
11664- previousProposal.user?.login === CONST_1.default.COMMENT.NAME_CODEX ||
11665- previousProposal.user?.login === CONST_1.default.COMMENT.NAME_GITHUB_ACTIONS ||
11666- previousProposal.user?.type === CONST_1.default.COMMENT.TYPE_BOT;
11688+ const isBotAuthor = getIsBotAuthor(previousProposal.user);
1166711689 // Skip prompting if comment author is the GH bot
11668- if (isAuthorBot ) {
11690+ if (isBotAuthor ) {
1166911691 continue;
1167011692 }
1167111693 const duplicateCheckPrompt = proposalPolice_1.default.getPromptForNewProposalDuplicateCheck(previousProposal.body, newProposalBody);
0 commit comments