diff --git a/extension/src/cli/dvc/reader.ts b/extension/src/cli/dvc/reader.ts index dc10f92b8a..ebd9530aa8 100644 --- a/extension/src/cli/dvc/reader.ts +++ b/extension/src/cli/dvc/reader.ts @@ -38,7 +38,9 @@ export const autoRegisteredCommands = { DATA_STATUS: 'dataStatus', EXP_SHOW: 'expShow', PLOTS_DIFF: 'plotsDiff', - STAGE_LIST: 'listStages' + ROOT: 'root', + STAGE_LIST: 'listStages', + VERSION: 'version' } as const export class DvcReader extends DvcCli { diff --git a/extension/src/cli/git/executor.ts b/extension/src/cli/git/executor.ts index 69e4cff63d..008e4b3ea4 100644 --- a/extension/src/cli/git/executor.ts +++ b/extension/src/cli/git/executor.ts @@ -4,6 +4,7 @@ import { getOptions } from './options' import { typeCheckCommands } from '..' export const autoRegisteredCommands = { + GIT_INIT: 'gitInit', GIT_PUSH_BRANCH: 'pushBranch', GIT_RESET_WORKSPACE: 'resetWorkspace', GIT_STAGE_ALL: 'stageAll', @@ -17,7 +18,7 @@ export class GitExecutor extends GitCli { this ) - public init(cwd: string) { + public gitInit(cwd: string) { const options = getOptions(cwd, Command.INITIALIZE) return this.executeProcess(options) diff --git a/extension/src/cli/git/reader.ts b/extension/src/cli/git/reader.ts index 92a958b597..52abb6e15a 100644 --- a/extension/src/cli/git/reader.ts +++ b/extension/src/cli/git/reader.ts @@ -11,6 +11,7 @@ export const autoRegisteredCommands = { GIT_GET_REMOTE_URL: 'getRemoteUrl', GIT_GET_REPOSITORY_ROOT: 'getGitRepositoryRoot', GIT_HAS_CHANGES: 'hasChanges', + GIT_HAS_NO_COMMITS: 'hasNoCommits', GIT_LIST_UNTRACKED: 'listUntracked' } as const diff --git a/extension/src/extension.ts b/extension/src/extension.ts index 9c1fd8e3fd..ac2838ab76 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -56,6 +56,7 @@ import { LanguageClient } from './languageClient' import { collectRunningExperimentPids } from './experiments/processExecution/collect' import { registerPatchCommand } from './patch' import { DvcViewer } from './cli/dvc/viewer' +import { registerSetupCommands } from './setup/register' export class Extension extends Disposable { protected readonly internalCommands: InternalCommands @@ -215,6 +216,7 @@ export class Extension extends Disposable { this.connect ) registerPlotsCommands(this.plots, this.internalCommands, this.setup) + registerSetupCommands(this.setup, this.internalCommands, config) this.internalCommands.registerExternalCommand( RegisteredCommands.EXPERIMENT_AND_PLOTS_SHOW, async (context: VsCodeContext) => { diff --git a/extension/src/setup/index.ts b/extension/src/setup/index.ts index 84466a7d04..44a994f62c 100644 --- a/extension/src/setup/index.ts +++ b/extension/src/setup/index.ts @@ -1,11 +1,10 @@ -import { Event, EventEmitter, ViewColumn, commands } from 'vscode' +import { Event, EventEmitter, ViewColumn } from 'vscode' import { Disposable, Disposer } from '@hediet/std/disposable' import isEmpty from 'lodash.isempty' import { SetupData as TSetupData } from './webview/contract' import { WebviewMessages } from './webview/messages' import { findPythonBinForInstall } from './autoInstall' import { run, runWithRecheck, runWorkspace } from './runner' -import { pickFocusedProjects } from './quickPick' import { BaseWebview } from '../webview' import { ViewKey } from '../webview/constants' import { BaseRepository } from '../webview/repository' @@ -30,8 +29,8 @@ import { ContextKey, setContextValue } from '../vscode/context' import { DvcExecutor } from '../cli/dvc/executor' import { GitReader } from '../cli/git/reader' import { GitExecutor } from '../cli/git/executor' -import { RegisteredCliCommands, RegisteredCommands } from '../commands/external' -import { InternalCommands } from '../commands/internal' +import { RegisteredCommands } from '../commands/external' +import { AvailableCommands, InternalCommands } from '../commands/internal' import { Status } from '../status' import { WorkspaceExperiments } from '../experiments/workspace' import { DvcRunner } from '../cli/dvc/runner' @@ -59,11 +58,8 @@ export class Setup private dvcRoots: string[] = [] private readonly config: Config - private readonly dvcReader: DvcReader - private readonly dvcExecutor: DvcExecutor - private readonly gitReader: GitReader - private readonly gitExecutor: GitExecutor private readonly status: Status + private readonly internalCommands: InternalCommands private readonly webviewMessages: WebviewMessages private readonly showExperiments: () => void @@ -100,19 +96,17 @@ export class Setup super(GLOBAL_WEBVIEW_DVCROOT, webviewIcon) this.config = config - this.dvcExecutor = dvcExecutor - this.dvcReader = dvcReader - this.gitExecutor = gitExecutor - this.gitReader = gitReader + + this.internalCommands = internalCommands this.status = this.dispose.track( new Status( this.config, - this.dvcExecutor, - this.dvcReader, + dvcExecutor, + dvcReader, dvcRunner, - this.gitExecutor, - this.gitReader + gitExecutor, + gitReader ) ) @@ -134,8 +128,6 @@ export class Setup void experiments.showWebview(this.dvcRoots[0], ViewColumn.Active) } - this.registerCommands(internalCommands) - this.getHasData = () => experiments.getHasData() const onDidChangeHasData = experiments.columnsChanged.event this.dispose.track( @@ -161,7 +153,11 @@ export class Setup public async getCliVersion(cwd: string, tryGlobalCli?: true) { await this.config.isReady() try { - return await this.dvcReader.version(cwd, tryGlobalCli) + return await this.internalCommands.executeCommand( + AvailableCommands.VERSION, + cwd, + tryGlobalCli as unknown as string + ) } catch {} } @@ -257,21 +253,40 @@ export class Setup }) } - private createWebviewMessageHandler() { - const webviewMessages = new WebviewMessages( - () => this.getWebview(), - () => this.initializeDvc(), - () => this.initializeGit() - ) - this.dispose.track( - this.onDidReceivedWebviewMessage(message => - webviewMessages.handleMessageFromWebview(message) + public async setupWorkspace() { + const stopWatch = new StopWatch() + try { + const previousCliPath = this.config.getCliPath() + const previousPythonPath = this.config.getPythonBinPath() + + const completed = await this.runWorkspace() + sendTelemetryEvent( + RegisteredCommands.EXTENSION_SETUP_WORKSPACE, + { completed }, + { + duration: stopWatch.getElapsedTime() + } ) - ) - return webviewMessages + + const executionDetailsUnchanged = + this.config.getCliPath() === previousPythonPath && + this.config.getPythonBinPath() === previousCliPath + + if (completed && !this.cliAccessible && executionDetailsUnchanged) { + this.workspaceChanged.fire() + } + + return completed + } catch (error: unknown) { + return sendTelemetryEventAndThrow( + RegisteredCommands.EXTENSION_SETUP_WORKSPACE, + error as Error, + stopWatch.getElapsedTime() + ) + } } - private async findWorkspaceDvcRoots(): Promise { + public async findWorkspaceDvcRoots(): Promise { let dvcRoots: Set = new Set() for (const workspaceFolder of getWorkspaceFolders()) { @@ -284,7 +299,10 @@ export class Setup await this.config.isReady() const absoluteRoot = await findAbsoluteDvcRootPath( workspaceFolder, - this.dvcReader.root(workspaceFolder) + this.internalCommands.executeCommand( + AvailableCommands.ROOT, + workspaceFolder + ) ) if (absoluteRoot) { dvcRoots.add(absoluteRoot) @@ -297,6 +315,19 @@ export class Setup return [...dvcRoots] } + private createWebviewMessageHandler() { + const webviewMessages = new WebviewMessages( + () => this.getWebview(), + () => this.initializeGit() + ) + this.dispose.track( + this.onDidReceivedWebviewMessage(message => + webviewMessages.handleMessageFromWebview(message) + ) + ) + return webviewMessages + } + private setCommandsAvailability(available: boolean) { void setContextValue(ContextKey.COMMANDS_AVAILABLE, available) } @@ -310,13 +341,6 @@ export class Setup } } - private async initializeDvc() { - const root = getFirstWorkspaceFolder() - if (root) { - await this.dvcExecutor.init(root) - } - } - private async canGitInitialize(needsGitInit: boolean) { if (!needsGitInit) { return false @@ -341,7 +365,10 @@ export class Setup } try { - return !(await this.gitReader.getGitRepositoryRoot(cwd)) + return !(await this.internalCommands.executeCommand( + AvailableCommands.GIT_GET_REPOSITORY_ROOT, + cwd + )) } catch { return true } @@ -350,7 +377,7 @@ export class Setup private initializeGit() { const cwd = getFirstWorkspaceFolder() if (cwd) { - void this.gitExecutor.init(cwd) + void this.internalCommands.executeCommand(AvailableCommands.GIT_INIT, cwd) } } @@ -363,80 +390,10 @@ export class Setup if (!cwd) { return true } - return this.gitReader.hasNoCommits(cwd) - } - - private registerCommands(internalCommands: InternalCommands) { - internalCommands.registerExternalCliCommand( - RegisteredCliCommands.INIT, - () => this.initializeDvc() - ) - - internalCommands.registerExternalCommand( - RegisteredCommands.EXTENSION_CHECK_CLI_COMPATIBLE, - () => run(this) - ) - - this.dispose.track( - commands.registerCommand( - RegisteredCommands.EXTENSION_SETUP_WORKSPACE, - () => this.setupWorkspace() - ) + return this.internalCommands.executeCommand( + AvailableCommands.GIT_HAS_NO_COMMITS, + cwd ) - - internalCommands.registerExternalCommand( - RegisteredCommands.SETUP_SHOW, - async () => { - await this.showSetup() - } - ) - - internalCommands.registerExternalCommand( - RegisteredCommands.SELECT_FOCUSED_PROJECTS, - async () => { - const dvcRoots = await this.findWorkspaceDvcRoots() - const focusedProjects = await pickFocusedProjects( - dvcRoots, - this.dvcRoots - ) - if (focusedProjects) { - this.config.setFocusedProjectsOption(focusedProjects) - } - } - ) - } - - private async setupWorkspace() { - const stopWatch = new StopWatch() - try { - const previousCliPath = this.config.getCliPath() - const previousPythonPath = this.config.getPythonBinPath() - - const completed = await this.runWorkspace() - sendTelemetryEvent( - RegisteredCommands.EXTENSION_SETUP_WORKSPACE, - { completed }, - { - duration: stopWatch.getElapsedTime() - } - ) - - const executionDetailsUnchanged = - this.config.getCliPath() === previousPythonPath && - this.config.getPythonBinPath() === previousCliPath - - if (completed && !this.cliAccessible && executionDetailsUnchanged) { - this.workspaceChanged.fire() - } - - return completed - } catch (error: unknown) { - return sendTelemetryEventAndThrow( - RegisteredCommands.EXTENSION_SETUP_WORKSPACE, - error as Error, - stopWatch.getElapsedTime() - ) - } } private runWorkspace() { diff --git a/extension/src/setup/register.ts b/extension/src/setup/register.ts new file mode 100644 index 0000000000..b0286bd2a0 --- /dev/null +++ b/extension/src/setup/register.ts @@ -0,0 +1,56 @@ +import { commands } from 'vscode' +import { Setup } from '.' +import { run } from './runner' +import { pickFocusedProjects } from './quickPick' +import { AvailableCommands, InternalCommands } from '../commands/internal' +import { Config } from '../config' +import { RegisteredCliCommands, RegisteredCommands } from '../commands/external' +import { getFirstWorkspaceFolder } from '../vscode/workspaceFolders' + +export const registerSetupCommands = ( + setup: Setup, + internalCommands: InternalCommands, + config: Config +) => { + internalCommands.registerExternalCliCommand( + RegisteredCliCommands.INIT, + async () => { + const root = getFirstWorkspaceFolder() + if (root) { + await internalCommands.executeCommand(AvailableCommands.INIT, root) + } + } + ) + + internalCommands.registerExternalCommand( + RegisteredCommands.EXTENSION_CHECK_CLI_COMPATIBLE, + () => run(setup) + ) + + setup.dispose.track( + commands.registerCommand(RegisteredCommands.EXTENSION_SETUP_WORKSPACE, () => + setup.setupWorkspace() + ) + ) + + internalCommands.registerExternalCommand( + RegisteredCommands.SETUP_SHOW, + async () => { + await setup.showSetup() + } + ) + + internalCommands.registerExternalCommand( + RegisteredCommands.SELECT_FOCUSED_PROJECTS, + async () => { + const dvcRoots = await setup.findWorkspaceDvcRoots() + const focusedProjects = await pickFocusedProjects( + dvcRoots, + setup.getRoots() + ) + if (focusedProjects) { + config.setFocusedProjectsOption(focusedProjects) + } + } + ) +} diff --git a/extension/src/setup/webview/messages.ts b/extension/src/setup/webview/messages.ts index 2d792773c5..2688973751 100644 --- a/extension/src/setup/webview/messages.ts +++ b/extension/src/setup/webview/messages.ts @@ -10,20 +10,20 @@ import { sendTelemetryEvent } from '../../telemetry' import { EventName } from '../../telemetry/constants' import { selectPythonInterpreter } from '../../extensions/python' import { autoInstallDvc } from '../autoInstall' -import { RegisteredCommands } from '../../commands/external' +import { + RegisteredCliCommands, + RegisteredCommands +} from '../../commands/external' export class WebviewMessages { private readonly getWebview: () => BaseWebview | undefined - private readonly initializeDvc: () => Promise private readonly initializeGit: () => void constructor( getWebview: () => BaseWebview | undefined, - initializeDvc: () => Promise, initializeGit: () => void ) { this.getWebview = getWebview - this.initializeDvc = initializeDvc this.initializeGit = initializeGit } @@ -65,7 +65,7 @@ export class WebviewMessages { RegisteredCommands.EXTENSION_CHECK_CLI_COMPATIBLE ) case MessageFromWebviewType.INITIALIZE_DVC: - return this.initializeDvc() + return commands.executeCommand(RegisteredCliCommands.INIT) case MessageFromWebviewType.INITIALIZE_GIT: return this.gitInit() case MessageFromWebviewType.SHOW_SCM_PANEL: diff --git a/extension/src/test/cli/util.ts b/extension/src/test/cli/util.ts index 5944de9030..36af17dc14 100644 --- a/extension/src/test/cli/util.ts +++ b/extension/src/test/cli/util.ts @@ -36,7 +36,7 @@ export const initializeEmptyRepo = async (): Promise => { return '' } - await gitExecutor.init(TEMP_DIR) + await gitExecutor.gitInit(TEMP_DIR) return dvcExecutor.init(TEMP_DIR) } diff --git a/extension/src/test/suite/setup/index.test.ts b/extension/src/test/suite/setup/index.test.ts index 13074a63c0..964dba3dab 100644 --- a/extension/src/test/suite/setup/index.test.ts +++ b/extension/src/test/suite/setup/index.test.ts @@ -16,7 +16,10 @@ import { MessageFromWebviewType } from '../../../webview/contract' import { Disposable } from '../../../extension' import { Logger } from '../../../common/logger' import { BaseWebview } from '../../../webview' -import { RegisteredCommands } from '../../../commands/external' +import { + RegisteredCliCommands, + RegisteredCommands +} from '../../../commands/external' import { isDirectory } from '../../../fileSystem' import { gitPath } from '../../../cli/git/constants' import { join } from '../../util/path' @@ -72,7 +75,11 @@ suite('Setup Test Suite', () => { }).timeout(WEBVIEW_TEST_TIMEOUT) it('should handle an initialize project message from the webview', async () => { - const { messageSpy, setup, mockInitializeDvc } = buildSetup(disposable) + const { messageSpy, setup } = buildSetup(disposable) + + const mockExecuteCommand = stub(commands, 'executeCommand').resolves( + undefined + ) const webview = await setup.showWebview() await webview.isReady() @@ -84,17 +91,21 @@ suite('Setup Test Suite', () => { type: MessageFromWebviewType.INITIALIZE_DVC }) - expect(mockInitializeDvc).to.be.calledOnce + expect(mockExecuteCommand).to.be.calledWithExactly( + RegisteredCliCommands.INIT + ) }).timeout(WEBVIEW_TEST_TIMEOUT) it('should handle a check cli compatible message from the webview', async () => { - const { messageSpy, setup, mockExecuteCommand } = buildSetup(disposable) + const { messageSpy, setup } = buildSetup(disposable) const webview = await setup.showWebview() await webview.isReady() const mockMessageReceived = getMessageReceivedEmitter(webview) + const mockExecuteCommand = stub(commands, 'executeCommand').resolves(true) + messageSpy.resetHistory() mockMessageReceived.fire({ type: MessageFromWebviewType.CHECK_CLI_COMPATIBLE @@ -122,12 +133,16 @@ suite('Setup Test Suite', () => { }).timeout(WEBVIEW_TEST_TIMEOUT) it('should handle a select Python interpreter message from the webview', async () => { - const { messageSpy, setup, mockExecuteCommand } = buildSetup(disposable) + const { messageSpy, setup } = buildSetup(disposable) const setInterpreterCommand = 'python.setInterpreter' const webview = await setup.showWebview() await webview.isReady() + const mockExecuteCommand = stub(commands, 'executeCommand').resolves( + undefined + ) + const mockMessageReceived = getMessageReceivedEmitter(webview) messageSpy.resetHistory() @@ -139,12 +154,16 @@ suite('Setup Test Suite', () => { }).timeout(WEBVIEW_TEST_TIMEOUT) it('should handle a show source control panel message from the webview', async () => { - const { messageSpy, setup, mockExecuteCommand } = buildSetup(disposable) + const { messageSpy, setup } = buildSetup(disposable) const showScmPanelCommand = 'workbench.view.scm' const webview = await setup.showWebview() await webview.isReady() + const mockExecuteCommand = stub(commands, 'executeCommand').resolves( + undefined + ) + const mockMessageReceived = getMessageReceivedEmitter(webview) messageSpy.resetHistory() @@ -156,13 +175,15 @@ suite('Setup Test Suite', () => { }).timeout(WEBVIEW_TEST_TIMEOUT) it('should handle a setup the workspace message from the webview', async () => { - const { messageSpy, setup, mockExecuteCommand } = buildSetup(disposable) + const { messageSpy, setup } = buildSetup(disposable) const webview = await setup.showWebview() await webview.isReady() const mockMessageReceived = getMessageReceivedEmitter(webview) + const mockExecuteCommand = stub(commands, 'executeCommand').resolves(true) + messageSpy.resetHistory() mockMessageReceived.fire({ type: MessageFromWebviewType.SETUP_WORKSPACE @@ -194,11 +215,7 @@ suite('Setup Test Suite', () => { }).timeout(WEBVIEW_TEST_TIMEOUT) it('should close the webview and open the experiments when the setup is done', async () => { - const { setup, mockOpenExperiments } = buildSetup( - disposable, - undefined, - true - ) + const { setup, mockOpenExperiments } = buildSetup(disposable, true) const closeWebviewSpy = spy(BaseWebview.prototype, 'dispose') @@ -290,7 +307,6 @@ suite('Setup Test Suite', () => { it('should send the expected message to the webview when there is no DVC project in the workspace', async () => { const { config, setup, messageSpy } = buildSetup( disposable, - undefined, false, true, false, @@ -334,7 +350,6 @@ suite('Setup Test Suite', () => { it('should send the expected message to the webview when there is no commits in the git repository', async () => { const { config, setup, messageSpy } = buildSetup( disposable, - undefined, false, false, false, @@ -485,10 +500,7 @@ suite('Setup Test Suite', () => { }) it('should set dvc.pythonPath to the picked value when the user selects to pick a Python interpreter', async () => { - const { config, setup, mockExecuteCommand, mockVersion } = - buildSetup(disposable) - - mockExecuteCommand.restore() + const { config, setup, mockVersion } = buildSetup(disposable) stub(config, 'isPythonExtensionInstalled').returns(false) @@ -555,13 +567,16 @@ suite('Setup Test Suite', () => { }).timeout(WEBVIEW_TEST_TIMEOUT) it('should set the dvc.cli.incompatible context value', async () => { - const { config, mockExecuteCommand, mockRunSetup, mockVersion, setup } = - buildSetup(disposable, undefined, true, false, false) + const { config, mockRunSetup, mockVersion, setup } = buildSetup( + disposable, + true, + false, + false + ) mockRunSetup.restore() stub(config, 'isPythonExtensionUsed').returns(false) stub(config, 'getPythonBinPath').resolves(join('python')) - mockExecuteCommand.restore() mockVersion.resetBehavior() mockVersion .onFirstCall() diff --git a/extension/src/test/suite/setup/util.ts b/extension/src/test/suite/setup/util.ts index d39ecb7314..d279ce5a0f 100644 --- a/extension/src/test/suite/setup/util.ts +++ b/extension/src/test/suite/setup/util.ts @@ -1,7 +1,7 @@ import { join } from 'path' import { EventEmitter, commands } from 'vscode' import { Disposer } from '@hediet/std/disposable' -import { fake, SinonSpy, stub } from 'sinon' +import { fake, stub } from 'sinon' import { ensureDirSync } from 'fs-extra' import * as FileSystem from '../../../fileSystem' import { Setup } from '../../../setup' @@ -20,7 +20,7 @@ import { StopWatch } from '../../../util/time' import { WorkspaceScale } from '../../../telemetry/collect' import { dvcDemoPath } from '../../util' import { Config } from '../../../config' -import { Resource, ResourceLocator } from '../../../resourceLocator' +import { Resource } from '../../../resourceLocator' import { MIN_CLI_VERSION } from '../../../cli/dvc/contract' export const TEMP_DIR = join(dvcDemoPath, 'temp-empty-watcher-dir') @@ -88,37 +88,37 @@ const buildSetupDependencies = ( export const buildSetup = ( disposer: Disposer, - dependencies?: { - config: Config - messageSpy: SinonSpy<[data: unknown], Promise> - resourceLocator: ResourceLocator - }, hasData = false, noDvcRoot = true, noGitRoot = true, noGitCommits = true ) => { - const { config, messageSpy, resourceLocator } = - dependencies || buildDependencies(disposer) + const { + config, + messageSpy, + resourceLocator, + internalCommands, + dvcExecutor, + dvcReader, + dvcRunner, + gitExecutor, + gitReader + } = buildDependencies(disposer) const mockDvcRoot = noDvcRoot ? undefined : dvcDemoPath const mockGitRoot = noGitRoot ? undefined : dvcDemoPath - const { - mockDvcExecutor, - mockDvcReader, - mockDvcRunner, - mockExecuteCommand, - mockGitExecutor, - mockGitReader, - mockEmitter, - mockGetGitRepositoryRoot, - mockInitializeDvc, - mockInitializeGit, - mockInternalCommands, - mockRunSetup, - mockVersion - } = buildSetupDependencies(disposer, mockDvcRoot, mockGitRoot, noGitCommits) + const mockEmitter = disposer.track(new EventEmitter()) + stub(dvcReader, 'root').resolves(mockDvcRoot) + const mockVersion = stub(dvcReader, 'version').resolves(MIN_CLI_VERSION) + const mockGetGitRepositoryRoot = stub( + gitReader, + 'getGitRepositoryRoot' + ).resolves(mockGitRoot) + stub(gitReader, 'hasNoCommits').resolves(noGitCommits) + + const mockInitializeGit = stub(gitExecutor, 'gitInit') + stub(FileSystem, 'findDvcRootPaths').resolves( [mockDvcRoot].filter(Boolean) as string[] ) @@ -128,15 +128,17 @@ export const buildSetup = ( const mockOpenExperiments = fake() + const mockRunSetup = stub(Runner, 'run').resolves(undefined) + const setup = disposer.track( new Setup( new StopWatch(), config, - mockDvcExecutor, - mockDvcReader, - mockDvcRunner, - mockGitExecutor, - mockGitReader, + dvcExecutor, + dvcReader, + dvcRunner, + gitExecutor, + gitReader, () => Promise.resolve([undefined]), () => undefined, { @@ -144,7 +146,7 @@ export const buildSetup = ( getHasData: () => hasData, showWebview: mockOpenExperiments } as unknown as WorkspaceExperiments, - mockInternalCommands, + internalCommands, resourceLocator.dvcIcon, () => Promise.resolve({} as WorkspaceScale) ) @@ -152,11 +154,10 @@ export const buildSetup = ( return { config, + internalCommands, messageSpy, mockAutoInstallDvc, - mockExecuteCommand, mockGetGitRepositoryRoot, - mockInitializeDvc, mockInitializeGit, mockOpenExperiments, mockRunSetup, diff --git a/extension/src/test/suite/util.ts b/extension/src/test/suite/util.ts index 61741bb9a2..4def77c306 100644 --- a/extension/src/test/suite/util.ts +++ b/extension/src/test/suite/util.ts @@ -37,6 +37,7 @@ import { SetupData } from '../../setup/webview/contract' import { DvcViewer } from '../../cli/dvc/viewer' import { ConnectData } from '../../connect/webview/contract' import { Toast } from '../../vscode/toast' +import { GitExecutor } from '../../cli/git/executor' export const mockDisposable = { dispose: stub() @@ -152,6 +153,7 @@ export const buildInternalCommands = (disposer: Disposer) => { ) const dvcViewer = disposer.track(new DvcViewer(config)) const gitReader = disposer.track(new GitReader()) + const gitExecutor = disposer.track(new GitExecutor()) const outputChannel = disposer.track( new OutputChannel([dvcReader], '1', 'test output') @@ -164,6 +166,7 @@ export const buildInternalCommands = (disposer: Disposer) => { dvcReader, dvcRunner, dvcViewer, + gitExecutor, gitReader ) ) @@ -174,6 +177,7 @@ export const buildInternalCommands = (disposer: Disposer) => { dvcReader, dvcRunner, dvcViewer, + gitExecutor, gitReader, internalCommands } @@ -202,6 +206,7 @@ export const buildDependencies = ( dvcReader, dvcRunner, dvcViewer, + gitExecutor, gitReader, internalCommands } = buildInternalCommands(disposer) @@ -237,6 +242,7 @@ export const buildDependencies = ( dvcReader, dvcRunner, dvcViewer, + gitExecutor, gitReader, internalCommands, messageSpy,