Skip to content

Commit

Permalink
Merge branch 'master' into remove-checkout-commit-from-staged
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon authored Oct 7, 2021
2 parents 3d76aec + b88436a commit b2d04f5
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 14 deletions.
24 changes: 23 additions & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@
"command": "dvc.showExperiments",
"category": "DVC"
},
{
"title": "%command.showOutput%",
"command": "dvc.showOutput",
"category": "DVC"
},
{
"title": "%command.stopRunningExperiment%",
"command": "dvc.stopRunningExperiment",
Expand Down Expand Up @@ -456,8 +461,13 @@
},
{
"command": "dvc.checkout",
"group": "DVC",
"group": "1_DVC",
"when": "scmProvider == dvc && dvc.commands.available == true"
},
{
"command": "dvc.showOutput",
"group": "3_footer",
"when": "scmProvider == dvc"
}
],
"scm/resourceState/context": [
Expand Down Expand Up @@ -759,6 +769,18 @@
],
"when": "dvc.commands.available == true && dvc.project.available == true"
},
{
"id": "dvc.showOutput",
"title": "Output channel",
"description": "View the DVC output channel.\n[View output](command:dvc.showOutput)",
"media": {
"markdown": "resources/walkthrough/output-channel.md"
},
"completionEvents": [
"onCommand:dvc.showOutput"
],
"when": "dvc.commands.available == true && dvc.project.available == true"
},
{
"id": "dvc.scm",
"title": "Source control management",
Expand Down
1 change: 1 addition & 0 deletions extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"command.setupWorkspace": "Setup The Workspace",
"command.showCommands": "Show Commands",
"command.showExperiments": "Show Experiments",
"command.showOutput": "Show DVC Output",
"command.stopRunningExperiment": "Stop Running Experiment",
"command.views.experimentsFilterByTree.removeAllFilters": "Remove All Filters From Experiments Table",
"command.views.experimentsFilterByTree.removeFilter": "Remove Filter From Experiments Table",
Expand Down
16 changes: 16 additions & 0 deletions extension/resources/walkthrough/output-channel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Output channel

All commands which are run against the DVC CLI are logged into this extension's
dedicated output channel.

The channel will have two entries for each command that runs.

The first shows the command has started and the second is to signify that it has
completed.

The completion entry will show:

- The outcome of the command (COMPLETED / FAILED).
- Any non-zero exit codes.
- The length of time that each command took to run (ms).
- Any error message provided by the CLI.
1 change: 1 addition & 0 deletions extension/src/commands/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export enum RegisteredCommands {
EXTENSION_GET_STARTED = 'dvc.getStarted',
EXTENSION_SETUP_WORKSPACE = 'dvc.setupWorkspace',
EXTENSION_SHOW_COMMANDS = 'dvc.showCommands',
EXTENSION_SHOW_OUTPUT = 'dvc.showOutput',

DELETE_TARGET = 'dvc.deleteTarget',
MOVE_TARGETS = 'dvc.moveTargets',
Expand Down
15 changes: 14 additions & 1 deletion extension/src/commands/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Config } from '../config'
import { sendTelemetryEvent, sendTelemetryEventAndThrow } from '../telemetry'
import { StopWatch } from '../util/time'
import { OutputChannel } from '../vscode/outputChannel'
import { reportErrorWithOptions } from '../vscode/reporting'

type Command = (...args: Args) => unknown | Promise<unknown>

Expand Down Expand Up @@ -69,7 +70,7 @@ export class InternalCommands {
try {
return await this.runAndSendTelemetry<T>(name, func, arg)
} catch (e: unknown) {
this.outputChannel.offerToShowError()
this.offerToShowError()
}
})
)
Expand Down Expand Up @@ -126,4 +127,16 @@ export class InternalCommands {
private confirmedId(commandId: string): commandId is CommandId {
return Object.values(AvailableCommands).includes(commandId as CommandId)
}

private async offerToShowError() {
const show = 'Show'
const response = await reportErrorWithOptions(
'Something went wrong, please see the DVC output channel for more details.',
show,
'Close'
)
if (response === show) {
return this.outputChannel.show()
}
}
}
5 changes: 5 additions & 0 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ export class Extension implements IExtension {
})
)

this.internalCommands.registerExternalCommand(
RegisteredCommands.EXTENSION_SHOW_OUTPUT,
() => outputChannel.show()
)

registerRepositoryCommands(this.repositories, this.internalCommands)

reRegisterVsCodeCommands(this.internalCommands)
Expand Down
1 change: 1 addition & 0 deletions extension/src/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export interface IEventNamePropertyMapping {
[EventName.EXTENSION_GET_STARTED]: undefined
[EventName.EXTENSION_SETUP_WORKSPACE]: { completed: boolean }
[EventName.EXTENSION_SHOW_COMMANDS]: undefined
[EventName.EXTENSION_SHOW_OUTPUT]: undefined

[EventName.VIEWS_EXPERIMENTS_TREE_OPENED]: DvcRootCount
[EventName.VIEWS_EXPERIMENTS_FILTER_BY_TREE_OPENED]: DvcRootCount
Expand Down
11 changes: 10 additions & 1 deletion extension/src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { RegisteredCommands } from '../../commands/external'
import * as Setup from '../../setup'
import * as Telemetry from '../../telemetry'
import { EventName } from '../../telemetry/constants'
import { OutputChannel } from '../../vscode/outputChannel'

suite('Extension Test Suite', () => {
const dvcPathOption = 'dvc.dvcPath'
Expand Down Expand Up @@ -371,11 +372,19 @@ suite('Extension Test Suite', () => {
describe('dvc.showCommands', () => {
it('should show all of the dvc commands without error', async () => {
await expect(
commands.executeCommand('dvc.showCommands')
commands.executeCommand(RegisteredCommands.EXTENSION_SHOW_COMMANDS)
).to.be.eventually.equal(undefined)
})
})

describe('dvc.showOutput', () => {
it('should be able to show the output channel', async () => {
const showOutputSpy = spy(OutputChannel.prototype, 'show')
await commands.executeCommand(RegisteredCommands.EXTENSION_SHOW_OUTPUT)
expect(showOutputSpy).to.have.been.calledOnce
})
})

describe('view container', () => {
it('should be able to focus the experiments view container', async () => {
await expect(
Expand Down
13 changes: 2 additions & 11 deletions extension/src/vscode/outputChannel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Disposable } from '@hediet/std/disposable'
import { OutputChannel as VSOutputChannel, window } from 'vscode'
import { reportErrorWithOptions } from './reporting'
import { ICli } from '../cli'

enum ProcessStatus {
Expand All @@ -24,16 +23,8 @@ export class OutputChannel {
})
}

public async offerToShowError() {
const show = 'Show'
const response = await reportErrorWithOptions(
'Something went wrong, please see the DVC output channel for more details.',
show,
'Close'
)
if (response === show) {
return this.outputChannel.show()
}
public show() {
return this.outputChannel.show()
}

private onDidStartProcess(cli: ICli) {
Expand Down

0 comments on commit b2d04f5

Please sign in to comment.