From 8b6e80b5246c588ff6c0ad30e9a2f1c42abd6fe3 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 6 Mar 2024 16:25:42 -0800 Subject: [PATCH 01/12] Use new report issue command api --- package.json | 8 +++++++- .../common/application/commands/reportIssueCommand.ts | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c211df36a0d6..110ffc4e5145 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "testObserver", "quickPickItemTooltip", "terminalDataWriteEvent", - "terminalExecuteCommandEvent" + "terminalExecuteCommandEvent", + "contribIssueReporter" ], "author": { "name": "Microsoft Corporation" @@ -1245,6 +1246,11 @@ } ], "menus": { + "issue/reporter": [ + { + "command": "python.reportIssue" + } + ], "commandPalette": [ { "category": "Python", diff --git a/src/client/common/application/commands/reportIssueCommand.ts b/src/client/common/application/commands/reportIssueCommand.ts index d18299e6698e..c078fc586565 100644 --- a/src/client/common/application/commands/reportIssueCommand.ts +++ b/src/client/common/application/commands/reportIssueCommand.ts @@ -106,6 +106,12 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ hasMultipleFoldersText, userSettings, ), + data: ` + # Diagnostic data + + - Python version (& distribution if applicable, e.g. Anaconda): 3.10.13 + - Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv + - Value of the python.languageServer setting: Default`, }); sendTelemetryEvent(EventName.USE_REPORT_ISSUE_COMMAND, undefined, {}); } From 40f39e8a035dcb37b33d4253a488dd07650e36b8 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 6 Mar 2024 17:54:04 -0800 Subject: [PATCH 02/12] update template --- resources/report_issue_template.md | 19 +------------------ resources/report_issue_user_data_template.md | 16 ++++++++++++++++ .../commands/reportIssueCommand.ts | 12 ++++-------- 3 files changed, 21 insertions(+), 26 deletions(-) create mode 100644 resources/report_issue_user_data_template.md diff --git a/resources/report_issue_template.md b/resources/report_issue_template.md index a0892ecba53b..bc81e1774e73 100644 --- a/resources/report_issue_template.md +++ b/resources/report_issue_template.md @@ -12,13 +12,9 @@ XXX **After** creating the issue on GitHub, you can add screenshots and GIFs of what is happening. Consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ for GIF creation. --> - + # Diagnostic data -- Python version (& distribution if applicable, e.g. Anaconda): {0} -- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): {1} -- Value of the `python.languageServer` setting: {2} -
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python) @@ -32,16 +28,3 @@ XXX

- -
- -User Settings - -

- -``` -{3}{4} -``` - -

-
diff --git a/resources/report_issue_user_data_template.md b/resources/report_issue_user_data_template.md new file mode 100644 index 000000000000..3440392caad2 --- /dev/null +++ b/resources/report_issue_user_data_template.md @@ -0,0 +1,16 @@ +- Python version (& distribution if applicable, e.g. Anaconda): {0} +- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): {1} +- Value of the `python.languageServer` setting: {2} + +
+ +User Settings + +

+ +``` +{3}{4} +``` + +

+
\ No newline at end of file diff --git a/src/client/common/application/commands/reportIssueCommand.ts b/src/client/common/application/commands/reportIssueCommand.ts index c078fc586565..a859063547a6 100644 --- a/src/client/common/application/commands/reportIssueCommand.ts +++ b/src/client/common/application/commands/reportIssueCommand.ts @@ -45,8 +45,8 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ } private argSettingsPath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_user_settings.json'); - private templatePath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_template.md'); + private userDataTemplatePath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_user_data_template.md'); public async openReportIssue(): Promise { const settings: IPythonSettings = this.configurationService.getSettings(); @@ -86,6 +86,7 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ } }); const template = await fs.readFile(this.templatePath, 'utf8'); + const userTemplate = await fs.readFile(this.userDataTemplatePath, 'utf8'); const interpreter = await this.interpreterService.getActiveInterpreter(); const pythonVersion = interpreter?.version?.raw ?? ''; const languageServer = @@ -99,19 +100,14 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ : ''; await this.commandManager.executeCommand('workbench.action.openIssueReporter', { extensionId: 'ms-python.python', - issueBody: template.format( + issueBody: template, + data: userTemplate.format( pythonVersion, virtualEnvKind, languageServer, hasMultipleFoldersText, userSettings, ), - data: ` - # Diagnostic data - - - Python version (& distribution if applicable, e.g. Anaconda): 3.10.13 - - Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv - - Value of the python.languageServer setting: Default`, }); sendTelemetryEvent(EventName.USE_REPORT_ISSUE_COMMAND, undefined, {}); } From 7dc5bfa7d95dfdb837c08581db147d12a3c8e451 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 7 Mar 2024 11:51:51 -0800 Subject: [PATCH 03/12] fix lint --- src/client/common/application/commands/reportIssueCommand.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client/common/application/commands/reportIssueCommand.ts b/src/client/common/application/commands/reportIssueCommand.ts index a859063547a6..b9acc7c0a163 100644 --- a/src/client/common/application/commands/reportIssueCommand.ts +++ b/src/client/common/application/commands/reportIssueCommand.ts @@ -45,7 +45,9 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ } private argSettingsPath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_user_settings.json'); + private templatePath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_template.md'); + private userDataTemplatePath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_user_data_template.md'); public async openReportIssue(): Promise { From d998b5ad7365708d87ad4eab5a57b24a8bf4632b Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 7 Mar 2024 11:52:22 -0800 Subject: [PATCH 04/12] fix tests --- ...issueTemplateVenv2.md => issueTemplate.md} | 25 +-------- .../commands/issueTemplateVenv1.md | 56 ------------------- .../commands/issueUserDataTemplateVenv1.md | 25 +++++++++ .../commands/issueUserDataTemplateVenv2.md | 22 ++++++++ .../commands/reportIssueCommand.unit.test.ts | 47 +++++++++++----- 5 files changed, 80 insertions(+), 95 deletions(-) rename src/test/common/application/commands/{issueTemplateVenv2.md => issueTemplate.md} (53%) delete mode 100644 src/test/common/application/commands/issueTemplateVenv1.md create mode 100644 src/test/common/application/commands/issueUserDataTemplateVenv1.md create mode 100644 src/test/common/application/commands/issueUserDataTemplateVenv2.md diff --git a/src/test/common/application/commands/issueTemplateVenv2.md b/src/test/common/application/commands/issueTemplate.md similarity index 53% rename from src/test/common/application/commands/issueTemplateVenv2.md rename to src/test/common/application/commands/issueTemplate.md index fa9142e5ca4d..bc81e1774e73 100644 --- a/src/test/common/application/commands/issueTemplateVenv2.md +++ b/src/test/common/application/commands/issueTemplate.md @@ -12,13 +12,9 @@ XXX **After** creating the issue on GitHub, you can add screenshots and GIFs of what is happening. Consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ for GIF creation. --> - + # Diagnostic data -- Python version (& distribution if applicable, e.g. Anaconda): 3.9.0 -- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv -- Value of the `python.languageServer` setting: Pylance -
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python) @@ -32,22 +28,3 @@ XXX

- -
- -User Settings - -

- -``` -Multiroot scenario, following user settings may not apply: - -experiments -• enabled: false - -venvPath: "" - -``` - -

-
diff --git a/src/test/common/application/commands/issueTemplateVenv1.md b/src/test/common/application/commands/issueTemplateVenv1.md deleted file mode 100644 index 09cdd2c32eb0..000000000000 --- a/src/test/common/application/commands/issueTemplateVenv1.md +++ /dev/null @@ -1,56 +0,0 @@ - -# Behaviour -## Expected vs. Actual - -XXX - -## Steps to reproduce: - -1. XXX - - - - -# Diagnostic data - -- Python version (& distribution if applicable, e.g. Anaconda): 3.9.0 -- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv -- Value of the `python.languageServer` setting: Pylance - -
- -Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python) - - -

- -``` -XXX -``` - -

-
- -
- -User Settings - -

- -``` - -experiments -• enabled: false -• optInto: [] -• optOutFrom: [] - -venvPath: "" - -pipenvPath: "" - -``` - -

-
diff --git a/src/test/common/application/commands/issueUserDataTemplateVenv1.md b/src/test/common/application/commands/issueUserDataTemplateVenv1.md new file mode 100644 index 000000000000..5b1c5188ae58 --- /dev/null +++ b/src/test/common/application/commands/issueUserDataTemplateVenv1.md @@ -0,0 +1,25 @@ +- Python version (& distribution if applicable, e.g. Anaconda): 3.9.0 +- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv +- Value of the `python.languageServer` setting: Pylance + +
+ +User Settings + +

+ +``` + +experiments +• enabled: false +• optInto: [] +• optOutFrom: [] + +venvPath: "" + +pipenvPath: "" + +``` + +

+
\ No newline at end of file diff --git a/src/test/common/application/commands/issueUserDataTemplateVenv2.md b/src/test/common/application/commands/issueUserDataTemplateVenv2.md new file mode 100644 index 000000000000..2c4275f6a792 --- /dev/null +++ b/src/test/common/application/commands/issueUserDataTemplateVenv2.md @@ -0,0 +1,22 @@ +- Python version (& distribution if applicable, e.g. Anaconda): 3.9.0 +- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv +- Value of the `python.languageServer` setting: Pylance + +
+ +User Settings + +

+ +``` +Multiroot scenario, following user settings may not apply: + +experiments +• enabled: false + +venvPath: "" + +``` + +

+
\ No newline at end of file diff --git a/src/test/common/application/commands/reportIssueCommand.unit.test.ts b/src/test/common/application/commands/reportIssueCommand.unit.test.ts index 92b4c0725f3f..def80bc34e68 100644 --- a/src/test/common/application/commands/reportIssueCommand.unit.test.ts +++ b/src/test/common/application/commands/reportIssueCommand.unit.test.ts @@ -38,6 +38,7 @@ suite('Report Issue Command', () => { let interpreterService: IInterpreterService; let configurationService: IConfigurationService; let appEnvironment: IApplicationEnvironment; + let expectedIssueBody: string; setup(async () => { workspaceService = mock(WorkspaceService); @@ -79,6 +80,17 @@ suite('Report Issue Command', () => { instance(appEnvironment), ); await reportIssueCommandHandler.activate(); + + const issueTemplatePath = path.join( + EXTENSION_ROOT_DIR_FOR_TESTS, + 'src', + 'test', + 'common', + 'application', + 'commands', + 'issueTemplate.md', + ); + expectedIssueBody = fs.readFileSync(issueTemplatePath, 'utf8'); }); teardown(() => { @@ -88,30 +100,33 @@ suite('Report Issue Command', () => { test('Test if issue body is filled correctly when including all the settings', async () => { await reportIssueCommandHandler.openReportIssue(); - const templatePath = path.join( + const userDataTemplatePath = path.join( EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'test', 'common', 'application', 'commands', - 'issueTemplateVenv1.md', + 'issueUserDataTemplateVenv1.md', ); - const expectedIssueBody = fs.readFileSync(templatePath, 'utf8'); + const expectedData = fs.readFileSync(userDataTemplatePath, 'utf8'); - const args: [string, { extensionId: string; issueBody: string }] = capture< + const args: [string, { extensionId: string; issueBody: string, data: string }] = capture< AllCommands, - { extensionId: string; issueBody: string } + { extensionId: string; issueBody: string, data: string } >(cmdManager.executeCommand).last(); verify(cmdManager.registerCommand(Commands.ReportIssue, anything(), anything())).once(); verify(cmdManager.executeCommand('workbench.action.openIssueReporter', anything())).once(); expect(args[0]).to.be.equal('workbench.action.openIssueReporter'); - const actual = args[1].issueBody; - expect(actual).to.be.equal(expectedIssueBody); + const issueBody = args[1].issueBody; + const data = args[1].data; + expect(issueBody).to.be.equal(expectedIssueBody); + expect(data).to.be.equal(expectedData); + }); - test('Test if issue body is filled when only including settings which are explicitly set', async () => { + test.only('Test if issue body is filled when only including settings which are explicitly set', async () => { // eslint-disable-next-line import/no-dynamic-require when(appEnvironment.packageJson).thenReturn(require(path.join(EXTENSION_ROOT_DIR, 'package.json'))); when(workspaceService.workspaceFolders).thenReturn([ @@ -128,26 +143,28 @@ suite('Report Issue Command', () => { await reportIssueCommandHandler.activate(); await reportIssueCommandHandler.openReportIssue(); - const templatePath = path.join( + const userDataTemplatePath = path.join( EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'test', 'common', 'application', 'commands', - 'issueTemplateVenv2.md', + 'issueUserDataTemplateVenv2.md', ); - const expectedIssueBody = fs.readFileSync(templatePath, 'utf8'); + const expectedData = fs.readFileSync(userDataTemplatePath, 'utf8'); - const args: [string, { extensionId: string; issueBody: string }] = capture< + const args: [string, { extensionId: string; issueBody: string, data: string }] = capture< AllCommands, - { extensionId: string; issueBody: string } + { extensionId: string; issueBody: string, data: string } >(cmdManager.executeCommand).last(); verify(cmdManager.executeCommand('workbench.action.openIssueReporter', anything())).once(); expect(args[0]).to.be.equal('workbench.action.openIssueReporter'); - const actual = args[1].issueBody; - expect(actual).to.be.equal(expectedIssueBody); + const issueBody = args[1].issueBody; + const data = args[1].data; + expect(issueBody).to.be.equal(expectedIssueBody); + expect(data).to.be.equal(expectedData); }); test('Should send telemetry event when run Report Issue Command', async () => { const sendTelemetryStub = sinon.stub(Telemetry, 'sendTelemetryEvent'); From aa7d475c8e5d1d9c15d205aaa4d9f61e5cf0be83 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 7 Mar 2024 11:53:59 -0800 Subject: [PATCH 05/12] fix lint --- .../application/commands/reportIssueCommand.unit.test.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/test/common/application/commands/reportIssueCommand.unit.test.ts b/src/test/common/application/commands/reportIssueCommand.unit.test.ts index def80bc34e68..e78d70e2ad59 100644 --- a/src/test/common/application/commands/reportIssueCommand.unit.test.ts +++ b/src/test/common/application/commands/reportIssueCommand.unit.test.ts @@ -111,9 +111,9 @@ suite('Report Issue Command', () => { ); const expectedData = fs.readFileSync(userDataTemplatePath, 'utf8'); - const args: [string, { extensionId: string; issueBody: string, data: string }] = capture< + const args: [string, { extensionId: string; issueBody: string; data: string }] = capture< AllCommands, - { extensionId: string; issueBody: string, data: string } + { extensionId: string; issueBody: string; data: string } >(cmdManager.executeCommand).last(); verify(cmdManager.registerCommand(Commands.ReportIssue, anything(), anything())).once(); @@ -123,7 +123,6 @@ suite('Report Issue Command', () => { const data = args[1].data; expect(issueBody).to.be.equal(expectedIssueBody); expect(data).to.be.equal(expectedData); - }); test.only('Test if issue body is filled when only including settings which are explicitly set', async () => { @@ -154,9 +153,9 @@ suite('Report Issue Command', () => { ); const expectedData = fs.readFileSync(userDataTemplatePath, 'utf8'); - const args: [string, { extensionId: string; issueBody: string, data: string }] = capture< + const args: [string, { extensionId: string; issueBody: string; data: string }] = capture< AllCommands, - { extensionId: string; issueBody: string, data: string } + { extensionId: string; issueBody: string; data: string } >(cmdManager.executeCommand).last(); verify(cmdManager.executeCommand('workbench.action.openIssueReporter', anything())).once(); From f8a69684d29b3b280fc6e99f986c8225899daa16 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 7 Mar 2024 13:17:27 -0800 Subject: [PATCH 06/12] fix lint --- .../application/commands/reportIssueCommand.unit.test.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/test/common/application/commands/reportIssueCommand.unit.test.ts b/src/test/common/application/commands/reportIssueCommand.unit.test.ts index e78d70e2ad59..45927cd19598 100644 --- a/src/test/common/application/commands/reportIssueCommand.unit.test.ts +++ b/src/test/common/application/commands/reportIssueCommand.unit.test.ts @@ -119,13 +119,12 @@ suite('Report Issue Command', () => { verify(cmdManager.registerCommand(Commands.ReportIssue, anything(), anything())).once(); verify(cmdManager.executeCommand('workbench.action.openIssueReporter', anything())).once(); expect(args[0]).to.be.equal('workbench.action.openIssueReporter'); - const issueBody = args[1].issueBody; - const data = args[1].data; + const {issueBody, data} = args[1]; expect(issueBody).to.be.equal(expectedIssueBody); expect(data).to.be.equal(expectedData); }); - test.only('Test if issue body is filled when only including settings which are explicitly set', async () => { + test('Test if issue body is filled when only including settings which are explicitly set', async () => { // eslint-disable-next-line import/no-dynamic-require when(appEnvironment.packageJson).thenReturn(require(path.join(EXTENSION_ROOT_DIR, 'package.json'))); when(workspaceService.workspaceFolders).thenReturn([ @@ -160,8 +159,7 @@ suite('Report Issue Command', () => { verify(cmdManager.executeCommand('workbench.action.openIssueReporter', anything())).once(); expect(args[0]).to.be.equal('workbench.action.openIssueReporter'); - const issueBody = args[1].issueBody; - const data = args[1].data; + const {issueBody, data} = args[1]; expect(issueBody).to.be.equal(expectedIssueBody); expect(data).to.be.equal(expectedData); }); From 3fd554a3163ef58290cfedda0f08ed86a3d34526 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 7 Mar 2024 13:21:41 -0800 Subject: [PATCH 07/12] run prettier --- .../application/commands/reportIssueCommand.unit.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/common/application/commands/reportIssueCommand.unit.test.ts b/src/test/common/application/commands/reportIssueCommand.unit.test.ts index 45927cd19598..cb42c7036634 100644 --- a/src/test/common/application/commands/reportIssueCommand.unit.test.ts +++ b/src/test/common/application/commands/reportIssueCommand.unit.test.ts @@ -119,7 +119,7 @@ suite('Report Issue Command', () => { verify(cmdManager.registerCommand(Commands.ReportIssue, anything(), anything())).once(); verify(cmdManager.executeCommand('workbench.action.openIssueReporter', anything())).once(); expect(args[0]).to.be.equal('workbench.action.openIssueReporter'); - const {issueBody, data} = args[1]; + const { issueBody, data } = args[1]; expect(issueBody).to.be.equal(expectedIssueBody); expect(data).to.be.equal(expectedData); }); @@ -159,7 +159,7 @@ suite('Report Issue Command', () => { verify(cmdManager.executeCommand('workbench.action.openIssueReporter', anything())).once(); expect(args[0]).to.be.equal('workbench.action.openIssueReporter'); - const {issueBody, data} = args[1]; + const { issueBody, data } = args[1]; expect(issueBody).to.be.equal(expectedIssueBody); expect(data).to.be.equal(expectedData); }); From 93113fdd1c1121863982961d18e941a293d63d65 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 7 Mar 2024 15:40:17 -0800 Subject: [PATCH 08/12] fix template --- resources/report_issue_template.md | 2 +- src/test/common/application/commands/issueTemplate.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/report_issue_template.md b/resources/report_issue_template.md index bc81e1774e73..5d562477e8b6 100644 --- a/resources/report_issue_template.md +++ b/resources/report_issue_template.md @@ -12,7 +12,7 @@ XXX **After** creating the issue on GitHub, you can add screenshots and GIFs of what is happening. Consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ for GIF creation. --> - + # Diagnostic data
diff --git a/src/test/common/application/commands/issueTemplate.md b/src/test/common/application/commands/issueTemplate.md index bc81e1774e73..5d562477e8b6 100644 --- a/src/test/common/application/commands/issueTemplate.md +++ b/src/test/common/application/commands/issueTemplate.md @@ -12,7 +12,7 @@ XXX **After** creating the issue on GitHub, you can add screenshots and GIFs of what is happening. Consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ for GIF creation. --> - + # Diagnostic data
From f7164047d036230de52ed4c8627ff9b76402ff41 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Tue, 12 Mar 2024 10:42:17 -0700 Subject: [PATCH 09/12] Get extensions --- resources/report_issue_template.md | 1 - resources/report_issue_user_data_template.md | 13 +++++++++---- .../application/commands/reportIssueCommand.ts | 11 +++++++++++ src/client/common/vscodeApis/extensionsApi.ts | 4 ++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/resources/report_issue_template.md b/resources/report_issue_template.md index 5d562477e8b6..a95af90ff7fe 100644 --- a/resources/report_issue_template.md +++ b/resources/report_issue_template.md @@ -1,6 +1,5 @@ # Behaviour -## Expected vs. Actual XXX diff --git a/resources/report_issue_user_data_template.md b/resources/report_issue_user_data_template.md index 3440392caad2..1e4af4f4b16f 100644 --- a/resources/report_issue_user_data_template.md +++ b/resources/report_issue_user_data_template.md @@ -3,14 +3,19 @@ - Value of the `python.languageServer` setting: {2}
- User Settings -

``` {3}{4} ``` -

-
\ No newline at end of file +
+ +
+Installed Extensions + +|Extension Name |Extension Id| Version| +|---|---|---| +{5} +
diff --git a/src/client/common/application/commands/reportIssueCommand.ts b/src/client/common/application/commands/reportIssueCommand.ts index b9acc7c0a163..0db8c80b51e7 100644 --- a/src/client/common/application/commands/reportIssueCommand.ts +++ b/src/client/common/application/commands/reportIssueCommand.ts @@ -19,6 +19,7 @@ import { EventName } from '../../../telemetry/constants'; import { EnvironmentType } from '../../../pythonEnvironments/info'; import { PythonSettings } from '../../configSettings'; import { SystemVariables } from '../../variables/systemVariables'; +import { getExtensions } from '../../vscodeApis/extensionsApi'; /** * Allows the user to report an issue related to the Python extension using our template. @@ -100,6 +101,15 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ hasMultipleFolders && userSettings !== '' ? `Multiroot scenario, following user settings may not apply:${os.EOL}` : ''; + + let installedExtensions = getExtensions() + .filter((extension) => !extension.id.startsWith('vscode.')) + .sort((a, b) => a.packageJSON.displayName.localeCompare(b.packageJSON.displayName)) + .map( + (extension) => + `|${extension.packageJSON.displayName}|${extension.id}|${extension.packageJSON.version}|`, + ); + await this.commandManager.executeCommand('workbench.action.openIssueReporter', { extensionId: 'ms-python.python', issueBody: template, @@ -109,6 +119,7 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ languageServer, hasMultipleFoldersText, userSettings, + installedExtensions.join('\n'), ), }); sendTelemetryEvent(EventName.USE_REPORT_ISSUE_COMMAND, undefined, {}); diff --git a/src/client/common/vscodeApis/extensionsApi.ts b/src/client/common/vscodeApis/extensionsApi.ts index ece424847a16..f021e9dc894a 100644 --- a/src/client/common/vscodeApis/extensionsApi.ts +++ b/src/client/common/vscodeApis/extensionsApi.ts @@ -32,3 +32,7 @@ export function isExtensionDisabled(extensionId: string): boolean { export function isInsider(): boolean { return vscode.env.appName.includes('Insider'); } + +export function getExtensions(): readonly vscode.Extension[] { + return vscode.extensions.all; +} From 8a216737c5a2756819bde343dd284dfe1b1e4760 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Tue, 12 Mar 2024 10:42:27 -0700 Subject: [PATCH 10/12] fix tests --- .../common/application/commands/issueTemplate.md | 1 - .../commands/issueUserDataTemplateVenv1.md | 13 +++++++++---- .../commands/issueUserDataTemplateVenv2.md | 13 +++++++++---- .../commands/reportIssueCommand.unit.test.ts | 13 +++++++++++++ 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/test/common/application/commands/issueTemplate.md b/src/test/common/application/commands/issueTemplate.md index 5d562477e8b6..a95af90ff7fe 100644 --- a/src/test/common/application/commands/issueTemplate.md +++ b/src/test/common/application/commands/issueTemplate.md @@ -1,6 +1,5 @@ # Behaviour -## Expected vs. Actual XXX diff --git a/src/test/common/application/commands/issueUserDataTemplateVenv1.md b/src/test/common/application/commands/issueUserDataTemplateVenv1.md index 5b1c5188ae58..6c0bb8bd0668 100644 --- a/src/test/common/application/commands/issueUserDataTemplateVenv1.md +++ b/src/test/common/application/commands/issueUserDataTemplateVenv1.md @@ -3,9 +3,7 @@ - Value of the `python.languageServer` setting: Pylance
- User Settings -

``` @@ -20,6 +18,13 @@ venvPath: "" pipenvPath: "" ``` -

-
\ No newline at end of file +
+ +
+Installed Extensions + +|Extension Name |Extension Id| Version| +|---|---|---| +|Python|ms-python.python|2020.2| +
diff --git a/src/test/common/application/commands/issueUserDataTemplateVenv2.md b/src/test/common/application/commands/issueUserDataTemplateVenv2.md index 2c4275f6a792..59dd0375fce6 100644 --- a/src/test/common/application/commands/issueUserDataTemplateVenv2.md +++ b/src/test/common/application/commands/issueUserDataTemplateVenv2.md @@ -3,9 +3,7 @@ - Value of the `python.languageServer` setting: Pylance
- User Settings -

``` @@ -17,6 +15,13 @@ experiments venvPath: "" ``` -

-
\ No newline at end of file + + +
+Installed Extensions + +|Extension Name |Extension Id| Version| +|---|---|---| +|Python|ms-python.python|2020.2| +
diff --git a/src/test/common/application/commands/reportIssueCommand.unit.test.ts b/src/test/common/application/commands/reportIssueCommand.unit.test.ts index cb42c7036634..2a35a6306cd2 100644 --- a/src/test/common/application/commands/reportIssueCommand.unit.test.ts +++ b/src/test/common/application/commands/reportIssueCommand.unit.test.ts @@ -30,6 +30,7 @@ import { IConfigurationService } from '../../../../client/common/types'; import { EventName } from '../../../../client/telemetry/constants'; import { EnvironmentType, PythonEnvironment } from '../../../../client/pythonEnvironments/info'; import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../../constants'; +import * as extensionsApi from '../../../../client/common/vscodeApis/extensionsApi'; suite('Report Issue Command', () => { let reportIssueCommandHandler: ReportIssueCommandHandler; @@ -39,6 +40,7 @@ suite('Report Issue Command', () => { let configurationService: IConfigurationService; let appEnvironment: IApplicationEnvironment; let expectedIssueBody: string; + let getExtensionsStub: sinon.SinonStub; setup(async () => { workspaceService = mock(WorkspaceService); @@ -46,6 +48,7 @@ suite('Report Issue Command', () => { interpreterService = mock(InterpreterService); configurationService = mock(ConfigurationService); appEnvironment = mock(); + getExtensionsStub = sinon.stub(extensionsApi, 'getExtensions'); when(cmdManager.executeCommand('workbench.action.openIssueReporter', anything())).thenResolve(); when(workspaceService.getConfiguration('python')).thenReturn( @@ -91,6 +94,16 @@ suite('Report Issue Command', () => { 'issueTemplate.md', ); expectedIssueBody = fs.readFileSync(issueTemplatePath, 'utf8'); + + getExtensionsStub.returns([ + { + id: 'ms-python.python', + packageJSON: { + displayName: 'Python', + version: '2020.2', + }, + }, + ]); }); teardown(() => { From a6291e7d1c39dbdcef48e5eb740fc36fd8611c50 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Tue, 12 Mar 2024 10:51:39 -0700 Subject: [PATCH 11/12] fix lint --- src/client/common/application/commands/reportIssueCommand.ts | 2 +- src/client/common/vscodeApis/extensionsApi.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/common/application/commands/reportIssueCommand.ts b/src/client/common/application/commands/reportIssueCommand.ts index 0db8c80b51e7..f5f1f0ac0c0e 100644 --- a/src/client/common/application/commands/reportIssueCommand.ts +++ b/src/client/common/application/commands/reportIssueCommand.ts @@ -102,7 +102,7 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ ? `Multiroot scenario, following user settings may not apply:${os.EOL}` : ''; - let installedExtensions = getExtensions() + const installedExtensions = getExtensions() .filter((extension) => !extension.id.startsWith('vscode.')) .sort((a, b) => a.packageJSON.displayName.localeCompare(b.packageJSON.displayName)) .map( diff --git a/src/client/common/vscodeApis/extensionsApi.ts b/src/client/common/vscodeApis/extensionsApi.ts index f021e9dc894a..8dfd610c490d 100644 --- a/src/client/common/vscodeApis/extensionsApi.ts +++ b/src/client/common/vscodeApis/extensionsApi.ts @@ -33,6 +33,7 @@ export function isInsider(): boolean { return vscode.env.appName.includes('Insider'); } -export function getExtensions(): readonly vscode.Extension[] { +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function getExtensions(): readonly vscode.Extension[] { return vscode.extensions.all; } From 0eb2ca43a18318f81efc114d7480dfd5df02836c Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Tue, 12 Mar 2024 10:54:58 -0700 Subject: [PATCH 12/12] fix code --- resources/report_issue_user_data_template.md | 2 +- src/client/common/vscodeApis/extensionsApi.ts | 2 +- .../common/application/commands/issueUserDataTemplateVenv1.md | 2 +- .../common/application/commands/issueUserDataTemplateVenv2.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/report_issue_user_data_template.md b/resources/report_issue_user_data_template.md index 1e4af4f4b16f..037b844511d3 100644 --- a/resources/report_issue_user_data_template.md +++ b/resources/report_issue_user_data_template.md @@ -15,7 +15,7 @@
Installed Extensions -|Extension Name |Extension Id| Version| +|Extension Name|Extension Id|Version| |---|---|---| {5}
diff --git a/src/client/common/vscodeApis/extensionsApi.ts b/src/client/common/vscodeApis/extensionsApi.ts index 8dfd610c490d..4e1664a3dfae 100644 --- a/src/client/common/vscodeApis/extensionsApi.ts +++ b/src/client/common/vscodeApis/extensionsApi.ts @@ -34,6 +34,6 @@ export function isInsider(): boolean { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -export function getExtensions(): readonly vscode.Extension[] { +export function getExtensions(): readonly vscode.Extension[] { return vscode.extensions.all; } diff --git a/src/test/common/application/commands/issueUserDataTemplateVenv1.md b/src/test/common/application/commands/issueUserDataTemplateVenv1.md index 6c0bb8bd0668..9c1aac03cf52 100644 --- a/src/test/common/application/commands/issueUserDataTemplateVenv1.md +++ b/src/test/common/application/commands/issueUserDataTemplateVenv1.md @@ -24,7 +24,7 @@ pipenvPath: ""
Installed Extensions -|Extension Name |Extension Id| Version| +|Extension Name|Extension Id|Version| |---|---|---| |Python|ms-python.python|2020.2|
diff --git a/src/test/common/application/commands/issueUserDataTemplateVenv2.md b/src/test/common/application/commands/issueUserDataTemplateVenv2.md index 59dd0375fce6..fa218fc35b04 100644 --- a/src/test/common/application/commands/issueUserDataTemplateVenv2.md +++ b/src/test/common/application/commands/issueUserDataTemplateVenv2.md @@ -21,7 +21,7 @@ venvPath: ""
Installed Extensions -|Extension Name |Extension Id| Version| +|Extension Name|Extension Id|Version| |---|---|---| |Python|ms-python.python|2020.2|