Skip to content

Commit 12116fb

Browse files
authored
Merge pull request #55330 from ikevin127/ikevin127-proposalPoliceSRFollowUp
[No QA] Proposal Police™ Structured Response Follow-Up
2 parents 225ec50 + 8b3b966 commit 12116fb

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

.github/actions/javascript/proposalPoliceComment/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18007,6 +18007,11 @@ async function run() {
1800718007
console.log('Comment body is either empty or doesn\'t contain the keyword "Proposal": ', payload.comment?.body);
1800818008
return;
1800918009
}
18010+
// If event is `edited` and comment was already edited by the bot, return early
18011+
if (isCommentEditedEvent(payload) && payload.comment?.body.trim().includes('Edited by **proposal-police**')) {
18012+
console.log('Comment was already edited by proposal-police once.\n', payload.comment?.body);
18013+
return;
18014+
}
1801018015
console.log('ProposalPolice™ Action triggered for comment:', payload.comment?.body);
1801118016
console.log('-> GitHub Action Type: ', payload.action?.toUpperCase());
1801218017
if (!isCommentCreatedEvent(payload) && !isCommentEditedEvent(payload)) {
@@ -18033,12 +18038,7 @@ async function run() {
1803318038
if (isCommentCreatedEvent(payload) && isActionRequired) {
1803418039
const formattedResponse = message
1803518040
// replace {user} from response template with @username
18036-
.replaceAll('{user}', `@${payload.comment?.user.login}`)
18037-
// replace {proposalLink} from response template with the link to the comment
18038-
.replaceAll('{proposalLink}', payload.comment?.html_url)
18039-
// remove any double quotes from the final comment because sometimes the assistant's
18040-
// response contains double quotes / sometimes it doesn't
18041-
.replaceAll('"', '');
18041+
.replaceAll('{user}', `@${payload.comment?.user.login}`);
1804218042
// Create a comment with the assistant's response
1804318043
console.log('ProposalPolice™ commenting on issue...');
1804418044
await GithubUtils_1.default.createComment(CONST_1.default.APP_REPO, github_1.context.issue.number, formattedResponse);

.github/actions/javascript/proposalPoliceComment/proposalPoliceComment.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ async function run() {
4141
return;
4242
}
4343

44+
// If event is `edited` and comment was already edited by the bot, return early
45+
if (isCommentEditedEvent(payload) && payload.comment?.body.trim().includes('Edited by **proposal-police**')) {
46+
console.log('Comment was already edited by proposal-police once.\n', payload.comment?.body);
47+
return;
48+
}
49+
4450
console.log('ProposalPolice™ Action triggered for comment:', payload.comment?.body);
4551
console.log('-> GitHub Action Type: ', payload.action?.toUpperCase());
4652

@@ -73,14 +79,7 @@ async function run() {
7379
if (isCommentCreatedEvent(payload) && isActionRequired) {
7480
const formattedResponse = message
7581
// replace {user} from response template with @username
76-
.replaceAll('{user}', `@${payload.comment?.user.login}`)
77-
78-
// replace {proposalLink} from response template with the link to the comment
79-
.replaceAll('{proposalLink}', payload.comment?.html_url)
80-
81-
// remove any double quotes from the final comment because sometimes the assistant's
82-
// response contains double quotes / sometimes it doesn't
83-
.replaceAll('"', '');
82+
.replaceAll('{user}', `@${payload.comment?.user.login}`);
8483

8584
// Create a comment with the assistant's response
8685
console.log('ProposalPolice™ commenting on issue...');

0 commit comments

Comments
 (0)