Skip to content

Commit

Permalink
Use new report issue command api (#23033)
Browse files Browse the repository at this point in the history
Use new report issue command api
microsoft/vscode-python-debugger#237
Modify the template, information about the installed extensions was
added
  • Loading branch information
paulacamargo25 committed Mar 13, 2024
1 parent 47a1876 commit 3775c93
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 116 deletions.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"testObserver",
"quickPickItemTooltip",
"terminalDataWriteEvent",
"terminalExecuteCommandEvent"
"terminalExecuteCommandEvent",
"contribIssueReporter"
],
"author": {
"name": "Microsoft Corporation"
Expand Down Expand Up @@ -1243,6 +1244,11 @@
}
],
"menus": {
"issue/reporter": [
{
"command": "python.reportIssue"
}
],
"commandPalette": [
{
"category": "Python",
Expand Down
20 changes: 1 addition & 19 deletions resources/report_issue_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<!-- Please fill in all XXX markers -->
# Behaviour
## Expected vs. Actual

XXX

Expand All @@ -12,13 +11,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.
-->

<!-- **NOTE**: Everything below except Python output panel is auto-generated; no editing required. Please do provide Python output panel. -->
<!-- **NOTE**: Please do provide logs from Python Output panel. -->
# 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}

<details>

<summary>Output for <code>Python</code> in the <code>Output</code> panel (<code>View</code>→<code>Output</code>, change the drop-down the upper-right of the <code>Output</code> panel to <code>Python</code>)
Expand All @@ -32,16 +27,3 @@ XXX

</p>
</details>

<details>

<summary>User Settings</summary>

<p>

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

</p>
</details>
21 changes: 21 additions & 0 deletions resources/report_issue_user_data_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- 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}

<details>
<summary>User Settings</summary>
<p>

```
{3}{4}
```
</p>
</details>

<details>
<summary>Installed Extensions</summary>

|Extension Name|Extension Id|Version|
|---|---|---|
{5}
</details>
17 changes: 16 additions & 1 deletion src/client/common/application/commands/reportIssueCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -48,6 +49,8 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ

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<void> {
const settings: IPythonSettings = this.configurationService.getSettings();
const argSettings = JSON.parse(await fs.readFile(this.argSettingsPath, 'utf8'));
Expand Down Expand Up @@ -86,6 +89,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 =
Expand All @@ -97,14 +101,25 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ
hasMultipleFolders && userSettings !== ''
? `Multiroot scenario, following user settings may not apply:${os.EOL}`
: '';

const 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.format(
issueBody: template,
data: userTemplate.format(
pythonVersion,
virtualEnvKind,
languageServer,
hasMultipleFoldersText,
userSettings,
installedExtensions.join('\n'),
),
});
sendTelemetryEvent(EventName.USE_REPORT_ISSUE_COMMAND, undefined, {});
Expand Down
5 changes: 5 additions & 0 deletions src/client/common/vscodeApis/extensionsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ export function isExtensionDisabled(extensionId: string): boolean {
export function isInsider(): boolean {
return vscode.env.appName.includes('Insider');
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function getExtensions(): readonly vscode.Extension<any>[] {
return vscode.extensions.all;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<!-- Please fill in all XXX markers -->
# Behaviour
## Expected vs. Actual

XXX

Expand All @@ -12,13 +11,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.
-->

<!-- **NOTE**: Everything below except Python output panel is auto-generated; no editing required. Please do provide Python output panel. -->
<!-- **NOTE**: Please do provide logs from Python Output panel. -->
# 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

<details>

<summary>Output for <code>Python</code> in the <code>Output</code> panel (<code>View</code>→<code>Output</code>, change the drop-down the upper-right of the <code>Output</code> panel to <code>Python</code>)
Expand All @@ -32,22 +27,3 @@ XXX

</p>
</details>

<details>

<summary>User Settings</summary>

<p>

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

</p>
</details>
56 changes: 0 additions & 56 deletions src/test/common/application/commands/issueTemplateVenv1.md

This file was deleted.

30 changes: 30 additions & 0 deletions src/test/common/application/commands/issueUserDataTemplateVenv1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
- 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

<details>
<summary>User Settings</summary>
<p>

```
experiments
• enabled: false
• optInto: []
• optOutFrom: []
venvPath: "<placeholder>"
pipenvPath: "<placeholder>"
```
</p>
</details>

<details>
<summary>Installed Extensions</summary>

|Extension Name|Extension Id|Version|
|---|---|---|
|Python|ms-python.python|2020.2|
</details>
27 changes: 27 additions & 0 deletions src/test/common/application/commands/issueUserDataTemplateVenv2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
- 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

<details>
<summary>User Settings</summary>
<p>

```
Multiroot scenario, following user settings may not apply:
experiments
• enabled: false
venvPath: "<placeholder>"
```
</p>
</details>

<details>
<summary>Installed Extensions</summary>

|Extension Name|Extension Id|Version|
|---|---|---|
|Python|ms-python.python|2020.2|
</details>

0 comments on commit 3775c93

Please sign in to comment.