Skip to content

Commit 4c2e0f0

Browse files
Copilotalexr00
andcommitted
Remove review.suggestDiff command completely
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 394692a commit 4c2e0f0

File tree

5 files changed

+0
-119
lines changed

5 files changed

+0
-119
lines changed

package.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,11 +1028,6 @@
10281028
"title": "%command.review.openLocalFile.title%",
10291029
"icon": "$(go-to-file)"
10301030
},
1031-
{
1032-
"command": "review.suggestDiff",
1033-
"title": "%command.review.suggestDiff.title%",
1034-
"category": "%command.pull.request.category%"
1035-
},
10361031
{
10371032
"command": "pr.refreshList",
10381033
"title": "%command.pr.refreshList.title%",
@@ -2097,10 +2092,6 @@
20972092
"command": "pr.openSessionLogFromDescription",
20982093
"when": "false"
20992094
},
2100-
{
2101-
"command": "review.suggestDiff",
2102-
"when": "false"
2103-
},
21042095
{
21052096
"command": "review.approve",
21062097
"when": "false"
@@ -3054,11 +3045,6 @@
30543045
}
30553046
],
30563047
"scm/title": [
3057-
{
3058-
"command": "review.suggestDiff",
3059-
"when": "scmProvider =~ /^git|^remoteHub:github/ && scmProviderRootUri in github:reposInReviewMode",
3060-
"group": "inline"
3061-
},
30623048
{
30633049
"command": "pr.create",
30643050
"when": "scmProvider =~ /^git|^remoteHub:github/ && scmProviderRootUri in github:reposNotInReviewMode",

package.nls.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@
202202
"command.pr.checkoutByNumber.title": "Checkout Pull Request by Number",
203203
"command.review.openFile.title": "Open File",
204204
"command.review.openLocalFile.title": "Open File",
205-
"command.review.suggestDiff.title": "Suggest Edit",
206205
"command.review.approve.title": "Approve",
207206
"command.review.comment.title": "Comment",
208207
"command.review.requestChanges.title": "Request Changes",

src/commands.ts

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -285,82 +285,6 @@ export function registerCommands(
285285
),
286286
);
287287

288-
context.subscriptions.push(
289-
vscode.commands.registerCommand('review.suggestDiff', async e => {
290-
const hasShownMessageKey = 'githubPullRequest.suggestDiffMessage';
291-
const hasShownMessage = context.globalState.get(hasShownMessageKey, false);
292-
if (!hasShownMessage) {
293-
await context.globalState.update(hasShownMessageKey, true);
294-
const documentation = vscode.l10n.t('Open documentation');
295-
const result = await vscode.window.showInformationMessage(vscode.l10n.t('You can now make suggestions from review comments, just like on GitHub.com. See the documentation for more details.'),
296-
{ modal: true }, documentation);
297-
if (result === documentation) {
298-
return vscode.env.openExternal(vscode.Uri.parse('https://github.com/microsoft/vscode-pull-request-github/blob/main/documentation/suggestAChange.md'));
299-
}
300-
}
301-
try {
302-
const folderManager = await chooseItem<FolderRepositoryManager>(
303-
reposManager.folderManagers,
304-
itemValue => pathLib.basename(itemValue.repository.rootUri.fsPath),
305-
);
306-
if (!folderManager || !folderManager.activePullRequest) {
307-
return;
308-
}
309-
310-
const { indexChanges, workingTreeChanges } = folderManager.repository.state;
311-
312-
if (!indexChanges.length) {
313-
if (workingTreeChanges.length) {
314-
const yes = vscode.l10n.t('Yes');
315-
const stageAll = await vscode.window.showWarningMessage(
316-
vscode.l10n.t('There are no staged changes to suggest.\n\nWould you like to automatically stage all your of changes and suggest them?'),
317-
{ modal: true },
318-
yes,
319-
);
320-
if (stageAll === yes) {
321-
await vscode.commands.executeCommand('git.stageAll');
322-
} else {
323-
return;
324-
}
325-
} else {
326-
vscode.window.showInformationMessage(vscode.l10n.t('There are no changes to suggest.'));
327-
return;
328-
}
329-
}
330-
331-
const diff = await folderManager.repository.diff(true);
332-
333-
let suggestEditMessage = vscode.l10n.t('Suggested edit:\n');
334-
if (e && e.inputBox && e.inputBox.value) {
335-
suggestEditMessage = `${e.inputBox.value}\n`;
336-
e.inputBox.value = '';
337-
}
338-
339-
const suggestEditText = `${suggestEditMessage}\`\`\`diff\n${diff}\n\`\`\``;
340-
await folderManager.activePullRequest.createIssueComment(suggestEditText);
341-
342-
// Reset HEAD and then apply reverse diff
343-
await vscode.commands.executeCommand('git.unstageAll');
344-
345-
const tempFilePath = pathLib.join(
346-
folderManager.repository.rootUri.fsPath,
347-
'.git',
348-
`${folderManager.activePullRequest.number}.diff`,
349-
);
350-
const encoder = new TextEncoder();
351-
const tempUri = vscode.Uri.file(tempFilePath);
352-
353-
await vscode.workspace.fs.writeFile(tempUri, encoder.encode(diff));
354-
await folderManager.repository.apply(tempFilePath, true);
355-
await vscode.workspace.fs.delete(tempUri);
356-
} catch (err) {
357-
const moreError = `${err}${err.stderr ? `\n${err.stderr}` : ''}`;
358-
Logger.error(`Applying patch failed: ${moreError}`, logId);
359-
vscode.window.showErrorMessage(vscode.l10n.t('Applying patch failed: {0}', formatError(err)));
360-
}
361-
}),
362-
);
363-
364288
context.subscriptions.push(
365289
vscode.commands.registerCommand('pr.openFileOnGitHub', async (e: GitFileChangeNode | RemoteFileChangeNode) => {
366290
if (e instanceof RemoteFileChangeNode) {

src/test/common/fixtures/gitdiff/03-large

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -866,11 +866,6 @@
866866
"title": "%command.review.openLocalFile.title%",
867867
"icon": "$(go-to-file)"
868868
},
869-
{
870-
"command": "review.suggestDiff",
871-
"title": "%command.review.suggestDiff.title%",
872-
"category": "%command.pull.request.category%"
873-
},
874869
{
875870
"command": "pr.refreshList",
876871
"title": "%command.pr.refreshList.title%",
@@ -1631,10 +1626,6 @@
16311626
"command": "pr.showDiffAll",
16321627
"when": "false"
16331628
},
1634-
{
1635-
"command": "review.suggestDiff",
1636-
"when": "false"
1637-
},
16381629
{
16391630
"command": "review.approve",
16401631
"when": "false"
@@ -2361,11 +2352,6 @@
23612352
}
23622353
],
23632354
"scm/title": [
2364-
{
2365-
"command": "review.suggestDiff",
2366-
"when": "scmProvider =~ /^git|^remoteHub:github/ && scmProviderRootUri in github:reposInReviewMode",
2367-
"group": "inline"
2368-
},
23692355
{
23702356
"command": "pr.create",
23712357
"when": "scmProvider =~ /^git|^remoteHub:github/ && scmProviderRootUri in github:reposNotInReviewMode",

src/test/common/fixtures/gitdiff/03-large-many-changes

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -849,11 +849,6 @@
849849
"title": "%command.review.openLocalFile.title%",
850850
"icon": "$(go-to-file)"
851851
},
852-
{
853-
"command": "review.suggestDiff",
854-
"title": "%command.review.suggestDiff.title%",
855-
"category": "%command.pull.request.category%"
856-
},
857852
{
858853
"command": "pr.refreshList",
859854
"title": "%command.pr.refreshList.title%",
@@ -1619,10 +1614,6 @@
16191614
"command": "pr.showDiffAll",
16201615
"when": "false"
16211616
},
1622-
{
1623-
"command": "review.suggestDiff",
1624-
"when": "false"
1625-
},
16261617
{
16271618
"command": "review.approve",
16281619
"when": "false"
@@ -2349,11 +2340,6 @@
23492340
}
23502341
],
23512342
"scm/title": [
2352-
{
2353-
"command": "review.suggestDiff",
2354-
"when": "scmProvider =~ /^git|^remoteHub:github/ && scmProviderRootUri in github:reposInReviewMode",
2355-
"group": "inline"
2356-
},
23572343
{
23582344
"command": "pr.create",
23592345
"when": "scmProvider =~ /^git|^remoteHub:github/ && scmProviderRootUri in github:reposNotInReviewMode",

0 commit comments

Comments
 (0)