Skip to content

Commit

Permalink
move flag argument out of dvc reader's version
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Mar 9, 2023
1 parent b027c46 commit 6440b70
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
9 changes: 7 additions & 2 deletions extension/src/cli/dvc/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const isDvcError = <
export const autoRegisteredCommands = {
DATA_STATUS: 'dataStatus',
EXP_SHOW: 'expShow',
GLOBAL_VERSION: 'globalVersion',
PLOTS_DIFF: 'plotsDiff',
ROOT: 'root',
STAGE_LIST: 'listStages',
Expand Down Expand Up @@ -106,9 +107,13 @@ export class DvcReader extends DvcCli {
} catch {}
}

public version(cwd: string, isCliGlobal?: true): Promise<string> {
public version(cwd: string): Promise<string> {
return this.executeDvcProcess(cwd, Flag.VERSION)
}

public globalVersion(cwd: string): Promise<string> {
const options = getOptions(
isCliGlobal ? undefined : this.config.getPythonBinPath(),
undefined,
this.config.getCliPath(),
cwd,
Flag.VERSION
Expand Down
9 changes: 7 additions & 2 deletions extension/src/setup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,15 @@ export class Setup
public async getCliVersion(cwd: string, tryGlobalCli?: true) {
await this.config.isReady()
try {
if (tryGlobalCli) {
return await this.internalCommands.executeCommand(
AvailableCommands.GLOBAL_VERSION,
cwd
)
}
return await this.internalCommands.executeCommand(
AvailableCommands.VERSION,
cwd,
tryGlobalCli as unknown as string
cwd
)
} catch {}
}
Expand Down
4 changes: 4 additions & 0 deletions extension/src/test/suite/setup/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export const buildSetup = (
const mockEmitter = disposer.track(new EventEmitter())
stub(dvcReader, 'root').resolves(mockDvcRoot)
const mockVersion = stub(dvcReader, 'version').resolves(MIN_CLI_VERSION)
const mockGlobalVersion = stub(dvcReader, 'globalVersion').resolves(
MIN_CLI_VERSION
)
const mockGetGitRepositoryRoot = stub(
gitReader,
'getGitRepositoryRoot'
Expand Down Expand Up @@ -87,6 +90,7 @@ export const buildSetup = (
messageSpy,
mockAutoInstallDvc,
mockGetGitRepositoryRoot,
mockGlobalVersion,
mockInitializeGit,
mockOpenExperiments,
mockRunSetup,
Expand Down

0 comments on commit 6440b70

Please sign in to comment.