Skip to content

Commit 9a95426

Browse files
authored
Check availability and compatibility on DVC projects in multi root workspaces (#2795)
1 parent 476ce75 commit 9a95426

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

extension/src/extension.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@ export class Extension extends Disposable implements IExtension {
379379
return this.setProjectAvailability()
380380
}
381381

382+
public getRoots() {
383+
return this.dvcRoots
384+
}
385+
382386
public async initialize() {
383387
this.resetMembers()
384388

extension/src/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export interface IExtension {
33
cwd: string,
44
isCliGlobal?: true
55
) => Promise<string | undefined>
6+
getRoots: () => string[]
67
hasRoots: () => boolean
78
isPythonExtensionUsed: () => Promise<boolean>
89

extension/src/setup.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const mockedCwd = __dirname
6565
const mockedGetCliVersion = jest.fn()
6666
const mockedGetFirstWorkspaceFolder = jest.mocked(getFirstWorkspaceFolder)
6767
const mockedHasRoots = jest.fn()
68+
const mockedGetRoots = jest.mocked(() => [])
6869
const mockedInitialize = jest.fn()
6970
const mockedIsPythonExtensionUsed = jest.fn()
7071
const mockedResetMembers = jest.fn()
@@ -258,6 +259,7 @@ describe('setupWorkspace', () => {
258259
describe('setup', () => {
259260
const extension = {
260261
getCliVersion: mockedGetCliVersion,
262+
getRoots: mockedGetRoots,
261263
hasRoots: mockedHasRoots,
262264
initialize: mockedInitialize,
263265
isPythonExtensionUsed: mockedIsPythonExtensionUsed,

extension/src/setup.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,13 @@ export const setup = async (extension: IExtension) => {
161161

162162
await extension.setRoots()
163163

164-
const { isAvailable, isCompatible } = await extensionCanRunCli(extension, cwd)
164+
const roots = extension.getRoots()
165+
const dvcRootOrFirstFolder = roots.length > 0 ? roots[0] : cwd
166+
167+
const { isAvailable, isCompatible } = await extensionCanRunCli(
168+
extension,
169+
dvcRootOrFirstFolder
170+
)
165171

166172
extension.setCliCompatible(isCompatible)
167173
extension.setAvailable(isAvailable)

0 commit comments

Comments
 (0)