-
Notifications
You must be signed in to change notification settings - Fork 510
Adds option to generate a bug report in GitHub #963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
daviwil
merged 3 commits into
PowerShell:master
from
PowerSchill:powerschill/bug_report
Oct 23, 2017
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import vscode = require('vscode'); | ||
import { SessionManager } from '../session'; | ||
import cp = require('child_process'); | ||
import Settings = require('../settings'); | ||
|
||
import window = vscode.window; | ||
const os = require("os"); | ||
|
||
import { IFeature, LanguageClient } from '../feature'; | ||
// import { IExtensionManagementService, LocalExtensionType, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement'; | ||
|
||
const extensionId: string = 'ms-vscode.PowerShell'; | ||
const extensionVersion: string = vscode.extensions.getExtension(extensionId).packageJSON.version; | ||
|
||
const queryStringPrefix: string = '?' | ||
|
||
var settings = Settings.load(); | ||
let project = settings.bugReporting.project; | ||
|
||
const issuesUrl: string = `${project}/issues/new` | ||
|
||
var extensions = vscode.extensions.all.filter(element => element.packageJSON.isBuiltin == false).sort((leftside, rightside): number => { | ||
if (leftside.packageJSON.name.toLowerCase() < rightside.packageJSON.name.toLowerCase()) return -1; | ||
if (leftside.packageJSON.name.toLowerCase() > rightside.packageJSON.name.toLowerCase()) return 1; | ||
return 0; | ||
}) | ||
|
||
export class GenerateBugReportFeature implements IFeature { | ||
|
||
private command: vscode.Disposable; | ||
private powerShellProcess: cp.ChildProcess; | ||
|
||
constructor(private sessionManager: SessionManager) { | ||
this.command = vscode.commands.registerCommand('PowerShell.GenerateBugReport', () => { | ||
|
||
|
||
var OutputChannel = window.createOutputChannel('Debug'); | ||
OutputChannel.show(); | ||
|
||
OutputChannel.appendLine('Starting Bug Report'); | ||
|
||
var body = encodeURIComponent(`## Issue Description ## | ||
|
||
I am experiencing a problem with... | ||
|
||
## Attached Logs ## | ||
|
||
Follow the instructions in the [README](https://github.com/PowerShell/vscode-powershell#reporting-problems) about capturing and sending logs. | ||
|
||
## Environment Information ## | ||
|
||
### Visual Studio Code ### | ||
|
||
| Name | Version | | ||
| --- | --- | | ||
| Operating System | ${os.type() + ' ' + os.arch() + ' ' + os.release()} | | ||
| VSCode | ${vscode.version}| | ||
| PowerShell Extension Version | ${extensionVersion} | | ||
|
||
### PowerShell Information ### | ||
|
||
${this.getRuntimeInfo()} | ||
|
||
### Visual Studio Code Extensions ### | ||
|
||
<details><summary>Visual Studio Code Extensions(Click to Expand)</summary> | ||
|
||
${this.generateExtensionTable(extensions)} | ||
</details> | ||
|
||
`); | ||
|
||
var encodedBody = encodeURIComponent(body); | ||
var fullUrl = `${issuesUrl}${queryStringPrefix}body=${encodedBody}`; | ||
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(fullUrl)); | ||
|
||
}); | ||
|
||
} | ||
|
||
|
||
public setLanguageClient(LanguageClient: LanguageClient) { | ||
// Not needed for this feature. | ||
} | ||
|
||
public dispose() { | ||
this.command.dispose(); | ||
} | ||
|
||
|
||
private generateExtensionTable(extensions): string { | ||
if (!extensions.length) { | ||
return 'none'; | ||
} | ||
|
||
let tableHeader = `|Extension|Author|Version|\n|---|---|---|`; | ||
const table = extensions.map(e => { | ||
|
||
if (e.packageJSON.isBuiltin == false) { | ||
return `|${e.packageJSON.name}|${e.packageJSON.publisher}|${e.packageJSON.version}|`; | ||
} | ||
}).join('\n'); | ||
|
||
const extensionTable = ` | ||
${tableHeader}\n${table}; | ||
`; | ||
// 2000 chars is browsers de-facto limit for URLs, 400 chars are allowed for other string parts of the issue URL | ||
// http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers | ||
// if (encodeURIComponent(extensionTable).length > 1600) { | ||
// return 'the listing length exceeds browsers\' URL characters limit'; | ||
// } | ||
|
||
return extensionTable; | ||
} | ||
|
||
private getRuntimeInfo() { | ||
|
||
var psOutput; | ||
var powerShellExePath = this.sessionManager.getPowerShellExePath(); | ||
var powerShellArgs = [ | ||
"-NoProfile", | ||
"-Command", | ||
'$PSVersionString = "|Name|Value|\n"; $PSVersionString += "|---|---|\n"; $PSVersionTable.keys | ForEach-Object { $PSVersionString += "|$_|$($PSVersionTable.Item($_))|\n" }; $PSVersionString' | ||
] | ||
|
||
var spawn = require('child_process').spawnSync; | ||
var child = spawn(powerShellExePath, powerShellArgs); | ||
return child.stdout.toString().replace(';', ','); | ||
|
||
} | ||
|
||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the ILogger interface for this instead of an output channel, it'll go to the PowerShell Extension Logs channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, actually that was just used for debugging my code. I will remove it. Unless you think it would be beneficial to put the information into the log file.