Skip to content

Commit

Permalink
Check availability and compatibility on DVC projects in multi root wo…
Browse files Browse the repository at this point in the history
…rkspaces (#2795)
  • Loading branch information
sroy3 authored Nov 18, 2022
1 parent 476ce75 commit 9a95426
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ export class Extension extends Disposable implements IExtension {
return this.setProjectAvailability()
}

public getRoots() {
return this.dvcRoots
}

public async initialize() {
this.resetMembers()

Expand Down
1 change: 1 addition & 0 deletions extension/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface IExtension {
cwd: string,
isCliGlobal?: true
) => Promise<string | undefined>
getRoots: () => string[]
hasRoots: () => boolean
isPythonExtensionUsed: () => Promise<boolean>

Expand Down
2 changes: 2 additions & 0 deletions extension/src/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const mockedCwd = __dirname
const mockedGetCliVersion = jest.fn()
const mockedGetFirstWorkspaceFolder = jest.mocked(getFirstWorkspaceFolder)
const mockedHasRoots = jest.fn()
const mockedGetRoots = jest.mocked(() => [])
const mockedInitialize = jest.fn()
const mockedIsPythonExtensionUsed = jest.fn()
const mockedResetMembers = jest.fn()
Expand Down Expand Up @@ -258,6 +259,7 @@ describe('setupWorkspace', () => {
describe('setup', () => {
const extension = {
getCliVersion: mockedGetCliVersion,
getRoots: mockedGetRoots,
hasRoots: mockedHasRoots,
initialize: mockedInitialize,
isPythonExtensionUsed: mockedIsPythonExtensionUsed,
Expand Down
8 changes: 7 additions & 1 deletion extension/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,13 @@ export const setup = async (extension: IExtension) => {

await extension.setRoots()

const { isAvailable, isCompatible } = await extensionCanRunCli(extension, cwd)
const roots = extension.getRoots()
const dvcRootOrFirstFolder = roots.length > 0 ? roots[0] : cwd

const { isAvailable, isCompatible } = await extensionCanRunCli(
extension,
dvcRootOrFirstFolder
)

extension.setCliCompatible(isCompatible)
extension.setAvailable(isAvailable)
Expand Down

0 comments on commit 9a95426

Please sign in to comment.