Skip to content

Commit f4d2518

Browse files
Copilotalexr00
andcommitted
Add comment and resolve commands implementation
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 27aed2f commit f4d2518

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,18 @@
11811181
"category": "%command.pull.request.category%",
11821182
"enablement": "!commentIsEmpty"
11831183
},
1184+
{
1185+
"command": "pr.createCommentAndResolve",
1186+
"title": "%command.pr.createCommentAndResolve.title%",
1187+
"category": "%command.pull.request.category%",
1188+
"enablement": "!commentIsEmpty"
1189+
},
1190+
{
1191+
"command": "pr.createSingleCommentAndResolve",
1192+
"title": "%command.pr.createSingleCommentAndResolve.title%",
1193+
"category": "%command.pull.request.category%",
1194+
"enablement": "!commentIsEmpty"
1195+
},
11841196
{
11851197
"command": "pr.makeSuggestion",
11861198
"title": "%command.pr.makeSuggestion.title%",
@@ -2290,6 +2302,14 @@
22902302
"command": "pr.createSingleComment",
22912303
"when": "false"
22922304
},
2305+
{
2306+
"command": "pr.createCommentAndResolve",
2307+
"when": "false"
2308+
},
2309+
{
2310+
"command": "pr.createSingleCommentAndResolve",
2311+
"when": "false"
2312+
},
22932313
{
22942314
"command": "pr.makeSuggestion",
22952315
"when": "false"
@@ -3221,6 +3241,16 @@
32213241
"command": "pr.createSingleComment",
32223242
"group": "inline@2",
32233243
"when": "config.githubPullRequests.defaultCommentType == review && ((commentController =~ /^github-browse/ && !prInDraft) || commentController =~ /^github-review/ && !reviewInDraftMode)"
3244+
},
3245+
{
3246+
"command": "pr.createCommentAndResolve",
3247+
"group": "inline@3",
3248+
"when": "commentThread =~ /canResolve/ && ((commentController =~ /^github-browse/ && prInDraft) || (commentController =~ /^github-review/ && reviewInDraftMode))"
3249+
},
3250+
{
3251+
"command": "pr.createSingleCommentAndResolve",
3252+
"group": "inline@3",
3253+
"when": "commentThread =~ /canResolve/ && config.githubPullRequests.defaultCommentType != review && ((commentController =~ /^github-browse/ && !prInDraft) || (commentController =~ /^github-review/ && !reviewInDraftMode))"
32243254
}
32253255
],
32263256
"comments/comment/editorActions": [

package.nls.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@
234234
"command.pr.deleteLocalBranchesNRemotes.title": "Delete local branches and remotes",
235235
"command.pr.createComment.title": "Add Review Comment",
236236
"command.pr.createSingleComment.title": "Add Comment",
237+
"command.pr.createCommentAndResolve.title": "Add Review Comment and Resolve",
238+
"command.pr.createSingleCommentAndResolve.title": "Add Comment and Resolve",
237239
"command.pr.makeSuggestion.title": "Make Code Suggestion",
238240
"command.pr.startReview.title": "Start Review",
239241
"command.pr.editComment.title": "Edit Comment",

src/commands.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,36 @@ export function registerCommands(
12091209
}),
12101210
);
12111211

1212+
context.subscriptions.push(
1213+
vscode.commands.registerCommand('pr.createCommentAndResolve', async (reply: CommentReply) => {
1214+
/* __GDPR__
1215+
"pr.createCommentAndResolve" : {}
1216+
*/
1217+
telemetry.sendTelemetryEvent('pr.createCommentAndResolve');
1218+
const handler = resolveCommentHandler(reply.thread);
1219+
1220+
if (handler) {
1221+
await handler.createOrReplyComment(reply.thread, reply.text, false);
1222+
await handler.resolveReviewThread(reply.thread);
1223+
}
1224+
}),
1225+
);
1226+
1227+
context.subscriptions.push(
1228+
vscode.commands.registerCommand('pr.createSingleCommentAndResolve', async (reply: CommentReply) => {
1229+
/* __GDPR__
1230+
"pr.createSingleCommentAndResolve" : {}
1231+
*/
1232+
telemetry.sendTelemetryEvent('pr.createSingleCommentAndResolve');
1233+
const handler = resolveCommentHandler(reply.thread);
1234+
1235+
if (handler) {
1236+
await handler.createOrReplyComment(reply.thread, reply.text, true);
1237+
await handler.resolveReviewThread(reply.thread);
1238+
}
1239+
}),
1240+
);
1241+
12121242
context.subscriptions.push(
12131243
vscode.commands.registerCommand('pr.makeSuggestion', async (reply: CommentReply | GHPRComment | undefined) => {
12141244
let potentialThread: GHPRCommentThread | undefined;

0 commit comments

Comments
 (0)