forked from microsoft/vscode-python-debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreportIssueCommand.ts
More file actions
44 lines (40 loc) · 2.2 KB
/
reportIssueCommand.ts
File metadata and controls
44 lines (40 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import * as fs from 'fs-extra';
import * as path from 'path';
import { executeCommand } from '../../vscodeapi';
import { EXTENSION_ROOT_DIR } from '../../constants';
import { sendTelemetryEvent } from '../../../telemetry';
import { EventName } from '../../../telemetry/constants';
import { PythonEnvironment } from '../../../envExtApi';
import { traceLog } from '../../log/logging';
import { getActiveEnvironmentPath, resolveEnvironment } from '../../python';
/**
* Allows the user to report an issue related to the Python Debugger extension using our template.
*/
export async function openReportIssue(): Promise<void> {
traceLog('openReportIssue: Starting report issue flow');
const templatePath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_template.md');
const userDataTemplatePath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_user_data_template.md');
const template = await fs.readFile(templatePath, 'utf8');
const userTemplate = await fs.readFile(userDataTemplatePath, 'utf8');
// get active environment and resolve it
const interpreterPath = await getActiveEnvironmentPath();
let interpreter: PythonEnvironment | undefined = undefined;
if (interpreterPath && 'environmentPath' in interpreterPath) {
interpreter = await resolveEnvironment(interpreterPath.environmentPath.fsPath);
} else if (interpreterPath && 'path' in interpreterPath) {
interpreter = await resolveEnvironment(interpreterPath.path);
}
const virtualEnvKind = interpreter && interpreter.envId ? interpreter.envId.managerId : 'Unknown';
const pythonVersion = interpreter?.version ?? 'unknown';
traceLog(`openReportIssue: Resolved pythonVersion='${pythonVersion}' envKind='${virtualEnvKind}'`);
await executeCommand('workbench.action.openIssueReporter', {
extensionId: 'ms-python.debugpy',
issueBody: template,
data: userTemplate.replace('{0}', pythonVersion).replace('{1}', virtualEnvKind),
});
sendTelemetryEvent(EventName.USE_REPORT_ISSUE_COMMAND, undefined, {});
traceLog('openReportIssue: Issue reporter command executed');
}