protected override Task <bool> RunCommandAsync(VersionControlItemList items, bool test, CancellationToken cancellationToken) { return(StatusView.ShowAsync(items, test, true)); }
private async Task <TestResult> RunCommandAsync(Commands cmd, bool test, bool projRecurse = true, CancellationToken cancellationToken = default) { VersionControlItemList items = GetItems(projRecurse); foreach (VersionControlItem it in items) { if (it.Repository == null) { if (cmd != Commands.Publish) { return(TestResult.NoVersionControl); } } else if (it.Repository.VersionControlSystem != null && !it.Repository.VersionControlSystem.IsInstalled) { return(TestResult.Disable); } } bool res = false; try { switch (cmd) { case Commands.Update: res = await UpdateCommand.UpdateAsync(items, test, cancellationToken); break; case Commands.Diff: res = await DiffCommand.Show(items, test); break; case Commands.Log: res = await LogCommand.Show(items, test); break; case Commands.Status: res = await StatusView.ShowAsync(items, test, false); break; case Commands.Add: res = await AddCommand.AddAsync(items, test, cancellationToken); break; case Commands.Remove: res = await RemoveCommand.RemoveAsync(items, test, cancellationToken); break; case Commands.Revert: res = await RevertCommand.RevertAsync(items, test, cancellationToken); break; case Commands.Lock: res = await LockCommand.LockAsync(items, test, cancellationToken); break; case Commands.Unlock: res = await UnlockCommand.UnlockAsync(items, test, cancellationToken); break; case Commands.Publish: VersionControlItem it = items [0]; if (items.Count == 1 && it.IsDirectory && it.WorkspaceObject != null) { res = PublishCommand.Publish(it.WorkspaceObject, it.Path, test); } break; case Commands.Annotate: res = await BlameCommand.Show(items, test); break; case Commands.CreatePatch: res = await CreatePatchCommand.CreatePatchAsync(items, test, cancellationToken); break; case Commands.Ignore: res = await IgnoreCommand.IgnoreAsync(items, test, cancellationToken); break; case Commands.Unignore: res = await UnignoreCommand.UnignoreAsync(items, test, cancellationToken); break; case Commands.ResolveConflicts: res = await ResolveConflictsCommand.ResolveConflicts(items, test); break; } } catch (OperationCanceledException) { return(TestResult.Disable); } catch (Exception ex) { if (test) { LoggingService.LogError(ex.ToString()); } else { MessageService.ShowError(GettextCatalog.GetString("Version control command failed."), ex); } return(TestResult.Disable); } return(res ? TestResult.Enable : TestResult.Disable); }