提交 731b76a3 编写于 作者: T Tomas Vik

refactor: indicate progress during branch checkout

上级 06888a24
......@@ -21,6 +21,7 @@ module.exports = {
showWarningMessage: jest.fn(),
showErrorMessage: jest.fn(),
createStatusBarItem: jest.fn(),
withProgress: jest.fn(),
},
commands: {
executeCommand: jest.fn(),
......@@ -43,4 +44,7 @@ module.exports = {
},
CancellationTokenSource: jest.fn(),
ThemeColor: jest.fn(color => color),
ProgressLocation: {
Notification: 'Notification',
},
};
......@@ -17,6 +17,7 @@ describe('checkout MR branch', () => {
lastCommitSha: mr.sha,
};
wrappedRepository = mockRepository as WrappedRepository;
(vscode.window.withProgress as jest.Mock).mockImplementation((_, task) => task());
});
afterEach(() => {
......
......@@ -2,7 +2,6 @@ import * as vscode from 'vscode';
import * as assert from 'assert';
import { MrItemModel } from '../data_providers/items/mr_item_model';
import { VS_COMMANDS } from '../command_names';
import { doNotAwait } from '../utils/do_not_await';
const handleGitError = async (e: { stderr: string }) => {
const SEE_GIT_LOG = 'See Git Log';
......@@ -22,9 +21,14 @@ export const checkoutMrBranch = async (mrItemModel: MrItemModel): Promise<void>
);
try {
const { repository } = mrItemModel;
doNotAwait(vscode.window.showInformationMessage('Fetching branches...'));
await repository.fetch();
await repository.checkout(mr.source_branch);
await vscode.window.withProgress(
{ location: vscode.ProgressLocation.Notification, title: `Checking out ${mr.source_branch}` },
async () => {
await repository.fetch();
await repository.checkout(mr.source_branch);
},
);
if (repository.lastCommitSha !== mr.sha) {
await vscode.window.showWarningMessage(
`Branch changed to ${mr.source_branch}, but it's out of sync with the remote branch. Synchronize it by pushing or pulling.`,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册