-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-row-selection
- Loading branch information
Showing
42 changed files
with
395 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import process from 'process' | ||
import { executeProcess, processExists } from './execution' | ||
|
||
describe('executeProcess', () => { | ||
it('should be able to run a process', async () => { | ||
const output = await executeProcess({ | ||
args: ['some', 'text'], | ||
cwd: __dirname, | ||
executable: 'echo' | ||
}) | ||
expect(output).toMatch(/some.*text/) | ||
}) | ||
|
||
it('should return the stderr if the process throws with stderr', async () => { | ||
await expect( | ||
executeProcess({ | ||
args: ['me', 'outside'], | ||
cwd: __dirname, | ||
executable: 'find' | ||
}) | ||
).rejects.toBeTruthy() | ||
}) | ||
}) | ||
|
||
describe('processExists', () => { | ||
it('should return true if the process exists', async () => { | ||
expect(await processExists(process.pid)).toBe(true) | ||
}) | ||
it('should return false if it does not', async () => { | ||
expect(await processExists(-123.321)).toBe(false) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { Setup } from '..' | ||
import { Flag, SubCommand } from '../../cli/dvc/constants' | ||
import { AvailableCommands, InternalCommands } from '../../commands/internal' | ||
import { definedAndNonEmpty } from '../../util/array' | ||
import { getInput } from '../../vscode/inputBox' | ||
import { quickPickYesOrNo } from '../../vscode/quickPick' | ||
import { Title } from '../../vscode/title' | ||
import { Toast } from '../../vscode/toast' | ||
import { getOnlyOrPickProject } from '../../workspace/util' | ||
|
||
const noExistingOrUserConfirms = async ( | ||
internalCommands: InternalCommands, | ||
dvcRoot: string | ||
): Promise<boolean | undefined> => { | ||
const remoteList = await internalCommands.executeCommand( | ||
AvailableCommands.REMOTE, | ||
dvcRoot, | ||
SubCommand.LIST | ||
) | ||
|
||
if (!remoteList) { | ||
return true | ||
} | ||
|
||
return await quickPickYesOrNo( | ||
'make this new remote the default', | ||
'keep the current default', | ||
{ | ||
placeHolder: 'Would you like to set this new remote as the default?', | ||
title: Title.SET_REMOTE_AS_DEFAULT | ||
} | ||
) | ||
} | ||
|
||
const addRemoteToProject = async ( | ||
internalCommands: InternalCommands, | ||
dvcRoot: string | ||
): Promise<void> => { | ||
const name = await getInput(Title.ENTER_REMOTE_NAME) | ||
if (!name) { | ||
return | ||
} | ||
|
||
const url = await getInput(Title.ENTER_REMOTE_URL) | ||
if (!url) { | ||
return | ||
} | ||
|
||
const args = [Flag.PROJECT, name, url] | ||
|
||
const shouldSetAsDefault = await noExistingOrUserConfirms( | ||
internalCommands, | ||
dvcRoot | ||
) | ||
if (shouldSetAsDefault === undefined) { | ||
return | ||
} | ||
|
||
if (shouldSetAsDefault) { | ||
args.unshift(Flag.DEFAULT) | ||
} | ||
|
||
return await Toast.showOutput( | ||
internalCommands.executeCommand( | ||
AvailableCommands.REMOTE, | ||
dvcRoot, | ||
SubCommand.ADD, | ||
...args | ||
) | ||
) | ||
} | ||
|
||
export const getAddRemoteCommand = | ||
(setup: Setup, internalCommands: InternalCommands) => | ||
async (): Promise<void> => { | ||
const dvcRoots = setup.getRoots() | ||
if (!definedAndNonEmpty(dvcRoots)) { | ||
return Toast.showError('Cannot add a remote without a DVC project') | ||
} | ||
const dvcRoot = await getOnlyOrPickProject(dvcRoots) | ||
|
||
if (!dvcRoot) { | ||
return | ||
} | ||
return addRemoteToProject(internalCommands, dvcRoot) | ||
} |
Oops, something went wrong.