Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus commit input box after SCM commit action #859

Merged
merged 3 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion extension/src/repository/commands/register.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { commands } from 'vscode'
import {
getResourceCommand,
getRootCommand,
getSimpleResourceCommand,
Resource,
Root
} from '.'
import { tryThenMaybeForce } from '../../cli/actions'
import { RegisteredCliCommands } from '../../commands/external'
import { AvailableCommands, InternalCommands } from '../../commands/internal'

Expand Down Expand Up @@ -33,7 +35,12 @@ const registerRootCommands = (internalCommands: InternalCommands) => {

internalCommands.registerExternalCliCommand<Root>(
RegisteredCliCommands.COMMIT,
getRootCommand(internalCommands, AvailableCommands.COMMIT)
async ({ rootUri }) => {
const cwd = rootUri.fsPath

await tryThenMaybeForce(internalCommands, AvailableCommands.COMMIT, cwd)
return commands.executeCommand('workbench.scm.focus')
}
)

internalCommands.registerExternalCliCommand<Root>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from 'path'
import { afterEach, beforeEach, describe, it, suite } from 'mocha'
import { expect } from 'chai'
import { stub, restore } from 'sinon'
import { stub, restore, spy } from 'sinon'
import { window, commands, Uri, MessageItem } from 'vscode'
import { Disposable } from '../../../extension'
import { CliExecutor } from '../../../cli/executor'
Expand Down Expand Up @@ -85,12 +85,15 @@ suite('Source Control Management Test Suite', () => {
expect(mockCheckout).to.be.calledWith(dvcDemoPath, relPath, '-f')
})

it('should be able to run dvc.commit without error', async () => {
it('should focus the git commit text input box after running dvc commit', async () => {
const mockCommit = stub(CliExecutor.prototype, 'commit').resolves('')
const executeCommandSpy = spy(commands, 'executeCommand')

await commands.executeCommand(RegisteredCliCommands.COMMIT, { rootUri })

expect(mockCommit).to.be.calledOnce
expect(executeCommandSpy).to.be.calledTwice
expect(executeCommandSpy).to.be.calledWith('workbench.scm.focus')
})

it('should prompt to force if dvc.commit fails', async () => {
Expand Down