From bc8b9691fddbc440c35c779ef8f61b2502c2cb81 Mon Sep 17 00:00:00 2001 From: Coen van den Munckhof Date: Tue, 29 Aug 2023 10:51:50 +0200 Subject: [PATCH] and removing unused method from interface --- .../ProcessExecutingGitCommander.cs | 7 +++++-- src/RepoM.Api/Git/RepositoryViewModel.cs | 3 ++- .../RepositoryExpressionEvaluator.cs | 10 ++-------- .../ActionAssociateFileV1Mapper.cs | 5 ----- .../ActionBrowseRepositoryV1Mapper.cs | 5 ----- .../ActionMappers/ActionBrowserV1Mapper.cs | 5 ----- .../ActionMappers/ActionCommandV1Mapper.cs | 5 ----- .../ActionMappers/ActionExecutableV1Mapper.cs | 5 ----- .../ActionMappers/ActionFolderV1Mapper.cs | 5 ----- .../ActionMappers/ActionForEachV1Mapper.cs | 5 ----- .../ActionGitCheckoutV1Mapper.cs | 5 ----- .../ActionMappers/ActionGitFetchV1Mapper.cs | 5 ----- .../ActionMappers/ActionGitPullV1Mapper.cs | 9 ++------- .../ActionMappers/ActionGitPushV1Mapper.cs | 5 ----- .../ActionIgnoreRepositoriesV1Mapper.cs | 5 ----- .../ActionMappers/ActionJustTextV1Mapper.cs | 5 ----- .../ActionMappers/ActionMapperComposition.cs | 2 +- .../ActionPinRepositoryV1Mapper.cs | 19 +++++++------------ .../ActionMappers/ActionSeparatorV1Mapper.cs | 5 ----- .../RepositoryActionPinRepositoryV1.cs | 3 --- .../IActionToRepositoryActionMapper.cs | 2 -- src/RepoM.App/MainWindow.xaml.cs | 6 +++--- ...onAzureDevOpsCreatePullRequestsV1Mapper.cs | 5 ----- ...ctionAzureDevOpsGetPullRequestsV1Mapper.cs | 5 ----- .../ActionClipboardCopyV1Mapper.cs | 5 ----- .../ActionHeidiDatabasesV1Mapper.cs | 5 ----- .../ActionSonarCloudV1Mapper.cs | 5 ----- .../ActionAssociateFileV1MapperTests.cs | 15 +-------------- .../ActionGitCheckoutV1MapperTests.cs | 13 ------------- ...reDevOpsCreatePullRequestsV1MapperTests.cs | 13 ------------- ...AzureDevOpsGetPullRequestsV1MapperTests.cs | 13 ------------- .../ActionClipboardCopyV1MapperTests.cs | 12 ------------ .../ActionHeidiDatabasesV1MapperTests.cs | 12 ------------ .../ActionSonarCloudV1MapperTests.cs | 12 ------------ 34 files changed, 23 insertions(+), 218 deletions(-) diff --git a/src/RepoM.Api/Git/ProcessExecution/ProcessExecutingGitCommander.cs b/src/RepoM.Api/Git/ProcessExecution/ProcessExecutingGitCommander.cs index 104e11fa..811d0fea 100644 --- a/src/RepoM.Api/Git/ProcessExecution/ProcessExecutingGitCommander.cs +++ b/src/RepoM.Api/Git/ProcessExecution/ProcessExecutingGitCommander.cs @@ -7,9 +7,12 @@ namespace RepoM.Api.Git.ProcessExecution; using System.Text; using System.Text.RegularExpressions; using System.Threading; +using RepoM.Core.Plugin.Repository; public partial class ProcessExecutingGitCommander : IGitCommander { + private const string GIT_EXE = "git"; + /// /// Starting with version 1.7.10, Git uses UTF-8. /// Use this encoding for Git input and output. @@ -108,13 +111,13 @@ private static void RedirectStderr(ProcessStartInfo startInfo) startInfo.StandardErrorEncoding = _encoding; } - private static string Start(Repository repository, string[] command, Action initialize) + private static string Start(IRepository repository, string[] command, Action initialize) { var timeout = (int)TimeSpan.FromSeconds(10).TotalMilliseconds; var psi = new ProcessStartInfo { - FileName = "git", + FileName = GIT_EXE, WorkingDirectory = repository.Path, }; diff --git a/src/RepoM.Api/Git/RepositoryViewModel.cs b/src/RepoM.Api/Git/RepositoryViewModel.cs index 358135e6..f9dba708 100644 --- a/src/RepoM.Api/Git/RepositoryViewModel.cs +++ b/src/RepoM.Api/Git/RepositoryViewModel.cs @@ -21,6 +21,7 @@ public RepositoryViewModel(Repository repository, IRepositoryMonitor monitor) _monitor = monitor ?? throw new ArgumentNullException(nameof(monitor)); Repository = repository ?? throw new ArgumentNullException(nameof(repository)); UpdateStampUtc = DateTime.UtcNow; + Tags = Repository.Tags.Select(tag => new TagViewModel(tag)).ToArray(); } public override bool Equals(object? obj) @@ -88,7 +89,7 @@ private void EnsureStatusCache() public bool HasUnpushedChanges => Repository.HasUnpushedChanges; - public TagViewModel[] Tags => Repository.Tags.Select(x => new TagViewModel(x)).ToArray() ?? Array.Empty(); + public TagViewModel[] Tags { get; } public override int GetHashCode() { diff --git a/src/RepoM.Api/IO/ExpressionEvaluator/RepositoryExpressionEvaluator.cs b/src/RepoM.Api/IO/ExpressionEvaluator/RepositoryExpressionEvaluator.cs index c8ed429c..03d3c8a8 100644 --- a/src/RepoM.Api/IO/ExpressionEvaluator/RepositoryExpressionEvaluator.cs +++ b/src/RepoM.Api/IO/ExpressionEvaluator/RepositoryExpressionEvaluator.cs @@ -36,7 +36,7 @@ public bool EvaluateBooleanExpression(string? value, IRepository? repository) try { - object? result = _expressionExecutor.Execute(RepositoryContext.Create(repository), value!); + var result = _expressionExecutor.Execute(RepositoryContext.Create(repository), value); if (result is null) { @@ -77,13 +77,7 @@ public string EvaluateStringExpression(string value, IRepository? repository) { try { - object? result = _expressionExecutor.Execute(RepositoryContext.Create(repository), value); - - // seems to be possible - if (result == null) - { - return string.Empty; - } + var result = _expressionExecutor.Execute(RepositoryContext.Create(repository), value); if (result is string s) { diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1Mapper.cs index 1fa6a7e1..d075b698 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1Mapper.cs @@ -28,11 +28,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) return action is RepositoryActionAssociateFileV1; } - public bool CanHandleMultipleRepositories() - { - return false; - } - IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionAssociateFileV1, repository.First()); diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowseRepositoryV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowseRepositoryV1Mapper.cs index 64b11546..8786ff33 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowseRepositoryV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowseRepositoryV1Mapper.cs @@ -26,11 +26,6 @@ bool IActionToRepositoryActionMapper.CanMap(Data.RepositoryAction action) return action is RepositoryActionBrowseRepositoryV1; } - bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories() - { - return false; - } - IEnumerable IActionToRepositoryActionMapper.Map(Data.RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionBrowseRepositoryV1, repository.First()); diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowserV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowserV1Mapper.cs index 2e8b02d5..8457812d 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowserV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowserV1Mapper.cs @@ -26,11 +26,6 @@ bool IActionToRepositoryActionMapper.CanMap(Data.RepositoryAction action) return action is RepositoryActionBrowserV1; } - bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories() - { - return false; - } - IEnumerable IActionToRepositoryActionMapper.Map(Data.RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionBrowserV1, repository.First()); diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionCommandV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionCommandV1Mapper.cs index 9bd68a08..d22d588d 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionCommandV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionCommandV1Mapper.cs @@ -26,11 +26,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) return action is RepositoryActionCommandV1; } - bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories() - { - return false; - } - IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionCommandV1, repository.First()); diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionExecutableV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionExecutableV1Mapper.cs index 75275fad..9b87434c 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionExecutableV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionExecutableV1Mapper.cs @@ -29,11 +29,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) return action is RepositoryActionExecutableV1; } - bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories() - { - return false; - } - IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionExecutableV1, repository.First()); diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionFolderV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionFolderV1Mapper.cs index 9b98fa16..894baa1c 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionFolderV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionFolderV1Mapper.cs @@ -25,11 +25,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) return action is RepositoryActionFolderV1; } - bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories() - { - return false; - } - IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionFolderV1, repository.First(), actionMapperComposition); diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionForEachV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionForEachV1Mapper.cs index 8f93f97e..74f3f010 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionForEachV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionForEachV1Mapper.cs @@ -26,11 +26,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) return action is RepositoryActionForEachV1; } - bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories() - { - return false; - } - IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionForEachV1, repository.First(), actionMapperComposition); diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitCheckoutV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitCheckoutV1Mapper.cs index 0861fc9e..7b0d6a52 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitCheckoutV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitCheckoutV1Mapper.cs @@ -28,11 +28,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) return action is RepositoryActionGitCheckoutV1; } - bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories() - { - return false; - } - IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionGitCheckoutV1, repository.First()); diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitFetchV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitFetchV1Mapper.cs index 4a862a90..b38ded03 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitFetchV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitFetchV1Mapper.cs @@ -27,11 +27,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) return action is RepositoryActionGitFetchV1; } - bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories() - { - return true; - } - IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repositories, ActionMapperComposition actionMapperComposition) { Repository[] repos = repositories as Repository[] ?? repositories.ToArray(); diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitPullV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitPullV1Mapper.cs index d3092eca..406b9316 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitPullV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitPullV1Mapper.cs @@ -27,14 +27,9 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) return action is RepositoryActionGitPullV1; } - bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories() + IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { - return true; - } - - IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repositories, ActionMapperComposition actionMapperComposition) - { - Repository[] repos = repositories as Repository[] ?? repositories.ToArray(); + Repository[] repos = repository as Repository[] ?? repository.ToArray(); if (Array.Exists(repos, r => !_expressionEvaluator.EvaluateBooleanExpression(action.Active, r))) { yield break; diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitPushV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitPushV1Mapper.cs index cd935750..c2709d4e 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitPushV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitPushV1Mapper.cs @@ -27,11 +27,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) return action is RepositoryActionGitPushV1; } - bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories() - { - return true; - } - IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repositories, ActionMapperComposition actionMapperComposition) { Repository[] repos = repositories as Repository[] ?? repositories.ToArray(); diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionIgnoreRepositoriesV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionIgnoreRepositoriesV1Mapper.cs index a1305c8e..1980d3c1 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionIgnoreRepositoriesV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionIgnoreRepositoriesV1Mapper.cs @@ -29,11 +29,6 @@ bool IActionToRepositoryActionMapper.CanMap(Data.RepositoryAction action) return action is RepositoryActionIgnoreRepositoryV1; } - bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories() - { - return true; - } - IEnumerable IActionToRepositoryActionMapper.Map(Data.RepositoryAction action, IEnumerable repositories, ActionMapperComposition actionMapperComposition) { Repository[] repos = repositories as Repository[] ?? repositories.ToArray(); diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionJustTextV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionJustTextV1Mapper.cs index f3b0846c..f2dfed75 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionJustTextV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionJustTextV1Mapper.cs @@ -26,11 +26,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) return action is RepositoryActionJustTextV1; } - public bool CanHandleMultipleRepositories() - { - return false; - } - IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionJustTextV1, repository.First()); diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionMapperComposition.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionMapperComposition.cs index 9690013c..ae969e97 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionMapperComposition.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionMapperComposition.cs @@ -18,7 +18,7 @@ public class ActionMapperComposition public ActionMapperComposition(IEnumerable deserializers, IRepositoryExpressionEvaluator repoExpressionEvaluator) { _repoExpressionEvaluator = repoExpressionEvaluator ?? throw new ArgumentNullException(nameof(repoExpressionEvaluator)); - _deserializers = deserializers.ToArray() ?? throw new ArgumentNullException(nameof(deserializers)); + _deserializers = deserializers.ToArray(); } public RepositoryActionBase[] Map(Data.RepositoryAction action, params Repository[] repositories) diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionPinRepositoryV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionPinRepositoryV1Mapper.cs index c2c1c349..6a19d84e 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionPinRepositoryV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionPinRepositoryV1Mapper.cs @@ -31,11 +31,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) return action is RepositoryActionPinRepositoryV1; } - public bool CanHandleMultipleRepositories() - { - return true; - } - IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { foreach (Repository r in repository) @@ -76,12 +71,12 @@ private IEnumerable Map(RepositoryActionPinRepositoryV1? a if (string.IsNullOrWhiteSpace(name)) { name = action.Mode switch - { - RepositoryActionPinRepositoryV1.PinMode.Toggle => currentlyPinned ? UNPIN : PIN, - RepositoryActionPinRepositoryV1.PinMode.Pin => PIN, - RepositoryActionPinRepositoryV1.PinMode.UnPin => UNPIN, - _ => throw new ArgumentOutOfRangeException("Unexpected value for mode."), - }; + { + RepositoryActionPinRepositoryV1.PinMode.Toggle => currentlyPinned ? UNPIN : PIN, + RepositoryActionPinRepositoryV1.PinMode.Pin => PIN, + RepositoryActionPinRepositoryV1.PinMode.UnPin => UNPIN, + _ => throw new NotImplementedException(), + }; } Git.RepositoryAction CreateAction(string name, Repository repository, bool newPinnedValue) @@ -97,7 +92,7 @@ Git.RepositoryAction CreateAction(string name, Repository repository, bool newPi RepositoryActionPinRepositoryV1.PinMode.Toggle => CreateAction(name, repository, !currentlyPinned), RepositoryActionPinRepositoryV1.PinMode.Pin => CreateAction(name, repository, true), RepositoryActionPinRepositoryV1.PinMode.UnPin => CreateAction(name, repository, false), - _ => throw new ArgumentOutOfRangeException(nameof(action.Mode), action.Mode, "Not expected"), + _ => throw new NotImplementedException(), }; } } \ No newline at end of file diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionSeparatorV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionSeparatorV1Mapper.cs index 591f1c30..439bdb59 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionSeparatorV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionSeparatorV1Mapper.cs @@ -22,11 +22,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) return action is RepositoryActionSeparatorV1; } - public bool CanHandleMultipleRepositories() - { - return true; - } - IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { foreach (Repository r in repository) diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/Data/Actions/RepositoryActionPinRepositoryV1.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/Data/Actions/RepositoryActionPinRepositoryV1.cs index c9a8d5b6..251914ff 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/Data/Actions/RepositoryActionPinRepositoryV1.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/Data/Actions/RepositoryActionPinRepositoryV1.cs @@ -34,9 +34,6 @@ public sealed class RepositoryActionPinRepositoryV1 : RepositoryAction /// public enum PinMode { - // when deserialization fails, this is the value. - Unknown, - /// /// Toggle /// diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/IActionToRepositoryActionMapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/IActionToRepositoryActionMapper.cs index 5126e84f..b8728487 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/IActionToRepositoryActionMapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/IActionToRepositoryActionMapper.cs @@ -9,7 +9,5 @@ public interface IActionToRepositoryActionMapper { bool CanMap(RepositoryAction action); - bool CanHandleMultipleRepositories(); - IEnumerable Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition); } diff --git a/src/RepoM.App/MainWindow.xaml.cs b/src/RepoM.App/MainWindow.xaml.cs index 9b0e0e0a..4d63b62b 100644 --- a/src/RepoM.App/MainWindow.xaml.cs +++ b/src/RepoM.App/MainWindow.xaml.cs @@ -31,12 +31,12 @@ namespace RepoM.App; /// public partial class MainWindow { + private volatile bool _refreshDelayed; private readonly IRepositoryActionProvider _repositoryActionProvider; private readonly IRepositoryIgnoreStore _repositoryIgnoreStore; private readonly DefaultRepositoryMonitor? _monitor; private readonly ITranslationService _translationService; private bool _closeOnDeactivate = true; - private bool _refreshDelayed; private DateTime _timeOfLastRefresh = DateTime.MinValue; private readonly IFileSystem _fileSystem; private readonly ActionExecutor _executor; @@ -540,11 +540,11 @@ private void OnTxtFilterTextChanged(object? sender, TextChangedEventArgs e) // Text has changed, capture the timestamp if (sender != null) { - _timeOfLastRefresh = DateTime.Now; + _timeOfLastRefresh = DateTime.UtcNow; } // Spin while updates are in progress - if (DateTime.Now - _timeOfLastRefresh < TimeSpan.FromMilliseconds(100)) + if (DateTime.UtcNow - _timeOfLastRefresh < TimeSpan.FromMilliseconds(100)) { if (!_refreshDelayed) { diff --git a/src/RepoM.Plugin.AzureDevOps/ActionProvider/ActionAzureDevOpsCreatePullRequestsV1Mapper.cs b/src/RepoM.Plugin.AzureDevOps/ActionProvider/ActionAzureDevOpsCreatePullRequestsV1Mapper.cs index 2da5cf47..4a22ee02 100644 --- a/src/RepoM.Plugin.AzureDevOps/ActionProvider/ActionAzureDevOpsCreatePullRequestsV1Mapper.cs +++ b/src/RepoM.Plugin.AzureDevOps/ActionProvider/ActionAzureDevOpsCreatePullRequestsV1Mapper.cs @@ -33,11 +33,6 @@ public bool CanMap(RepositoryAction action) return action is RepositoryActionAzureDevOpsCreatePullRequestsV1; } - public bool CanHandleMultipleRepositories() - { - return false; - } - public IEnumerable Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionAzureDevOpsCreatePullRequestsV1, repository.First()); diff --git a/src/RepoM.Plugin.AzureDevOps/ActionProvider/ActionAzureDevOpsGetPullRequestsV1Mapper.cs b/src/RepoM.Plugin.AzureDevOps/ActionProvider/ActionAzureDevOpsGetPullRequestsV1Mapper.cs index 10145379..e15f92d3 100644 --- a/src/RepoM.Plugin.AzureDevOps/ActionProvider/ActionAzureDevOpsGetPullRequestsV1Mapper.cs +++ b/src/RepoM.Plugin.AzureDevOps/ActionProvider/ActionAzureDevOpsGetPullRequestsV1Mapper.cs @@ -34,11 +34,6 @@ public bool CanMap(RepositoryAction action) return action is RepositoryActionAzureDevOpsGetPullRequestsV1; } - public bool CanHandleMultipleRepositories() - { - return false; - } - public IEnumerable Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionAzureDevOpsGetPullRequestsV1, repository.First()); diff --git a/src/RepoM.Plugin.Clipboard/ActionProvider/ActionClipboardCopyV1Mapper.cs b/src/RepoM.Plugin.Clipboard/ActionProvider/ActionClipboardCopyV1Mapper.cs index 1ff8d6dc..87b5d4b8 100644 --- a/src/RepoM.Plugin.Clipboard/ActionProvider/ActionClipboardCopyV1Mapper.cs +++ b/src/RepoM.Plugin.Clipboard/ActionProvider/ActionClipboardCopyV1Mapper.cs @@ -32,11 +32,6 @@ public bool CanMap(RepositoryAction action) return action is RepositoryActionClipboardCopyV1; } - public bool CanHandleMultipleRepositories() - { - return false; - } - public IEnumerable Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionClipboardCopyV1, repository.First()); diff --git a/src/RepoM.Plugin.Heidi/ActionProvider/ActionHeidiDatabasesV1Mapper.cs b/src/RepoM.Plugin.Heidi/ActionProvider/ActionHeidiDatabasesV1Mapper.cs index 252d0163..08669f9b 100644 --- a/src/RepoM.Plugin.Heidi/ActionProvider/ActionHeidiDatabasesV1Mapper.cs +++ b/src/RepoM.Plugin.Heidi/ActionProvider/ActionHeidiDatabasesV1Mapper.cs @@ -45,11 +45,6 @@ public bool CanMap(RepositoryAction action) return action is RepositoryActionHeidiDatabasesV1; } - public bool CanHandleMultipleRepositories() - { - return false; - } - public IEnumerable Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionHeidiDatabasesV1, repository.First()); diff --git a/src/RepoM.Plugin.SonarCloud/ActionSonarCloudV1Mapper.cs b/src/RepoM.Plugin.SonarCloud/ActionSonarCloudV1Mapper.cs index 7b127040..eeb8f3e2 100644 --- a/src/RepoM.Plugin.SonarCloud/ActionSonarCloudV1Mapper.cs +++ b/src/RepoM.Plugin.SonarCloud/ActionSonarCloudV1Mapper.cs @@ -32,11 +32,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) return action is RepositoryActionSonarCloudSetFavoriteV1; } - public bool CanHandleMultipleRepositories() - { - return false; - } - IEnumerable IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable repository, ActionMapperComposition actionMapperComposition) { return Map(action as RepositoryActionSonarCloudSetFavoriteV1, repository.First()); diff --git a/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1MapperTests.cs b/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1MapperTests.cs index cd0689e1..8f2386a0 100644 --- a/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1MapperTests.cs +++ b/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1MapperTests.cs @@ -42,20 +42,7 @@ public void Ctor_ShouldThrown_WhenArgumentIsNull() act2.Should().ThrowExactly(); } - [Fact] - public void CanHandleMultipleRepositories_ShouldReturnFalse() - { - // arrange - var sut = new ActionAssociateFileV1Mapper(_expressionEvaluator, _translationService) as IActionToRepositoryActionMapper; - - // act - var result = sut.CanHandleMultipleRepositories(); - - // assert - result.Should().BeFalse(); - } - - [Fact] + [Fact] public void CanMap_ShouldReturnFalse_WhenInputNull() { // arrange diff --git a/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitCheckoutV1MapperTests.cs b/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitCheckoutV1MapperTests.cs index 6172bc11..dd1c4fe4 100644 --- a/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitCheckoutV1MapperTests.cs +++ b/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitCheckoutV1MapperTests.cs @@ -40,19 +40,6 @@ public void Ctor_ShouldThrown_WhenArgumentIsNull() act3.Should().ThrowExactly(); } - [Fact] - public void CanHandleMultipleRepositories_ShouldReturnFalse() - { - // arrange - var sut = new ActionGitCheckoutV1Mapper(_expressionEvaluator, _translationService, _repositoryWriter) as IActionToRepositoryActionMapper; - - // act - var result = sut.CanHandleMultipleRepositories(); - - // assert - result.Should().BeFalse(); - } - [Fact] public void CanMap_ShouldReturnFalse_WhenInputNull() { diff --git a/tests/RepoM.Plugin.AzureDevOps.Tests/ActionProvider/ActionAzureDevOpsCreatePullRequestsV1MapperTests.cs b/tests/RepoM.Plugin.AzureDevOps.Tests/ActionProvider/ActionAzureDevOpsCreatePullRequestsV1MapperTests.cs index b01c416c..b42bfeb6 100644 --- a/tests/RepoM.Plugin.AzureDevOps.Tests/ActionProvider/ActionAzureDevOpsCreatePullRequestsV1MapperTests.cs +++ b/tests/RepoM.Plugin.AzureDevOps.Tests/ActionProvider/ActionAzureDevOpsCreatePullRequestsV1MapperTests.cs @@ -53,19 +53,6 @@ public ActionAzureDevOpsCreatePullRequestsV1MapperTests() A.CallTo(() => _evaluator.EvaluateStringExpression("dummy-project-id", A._)).Returns("real-project-id"); } - [Fact] - public void CanHandleMultipleRepositories_ShouldReturnFalse() - { - // arrange - - // act - var result = _sut.CanHandleMultipleRepositories(); - - // assert - result.Should().BeFalse(); - A.CallTo(_service).MustNotHaveHappened(); - } - [Fact] public void CanMap_ShouldReturnFalse_WhenInputIsNotValidType() { diff --git a/tests/RepoM.Plugin.AzureDevOps.Tests/ActionProvider/ActionAzureDevOpsGetPullRequestsV1MapperTests.cs b/tests/RepoM.Plugin.AzureDevOps.Tests/ActionProvider/ActionAzureDevOpsGetPullRequestsV1MapperTests.cs index ceff4142..46770624 100644 --- a/tests/RepoM.Plugin.AzureDevOps.Tests/ActionProvider/ActionAzureDevOpsGetPullRequestsV1MapperTests.cs +++ b/tests/RepoM.Plugin.AzureDevOps.Tests/ActionProvider/ActionAzureDevOpsGetPullRequestsV1MapperTests.cs @@ -45,19 +45,6 @@ public ActionAzureDevOpsGetPullRequestsV1MapperTests() A.CallTo(() => _evaluator.EvaluateStringExpression("dummy-project-id", A._)).Returns("real-project-id"); } - [Fact] - public void CanHandleMultipleRepositories_ShouldReturnFalse() - { - // arrange - - // act - var result = _sut.CanHandleMultipleRepositories(); - - // assert - result.Should().BeFalse(); - A.CallTo(_service).MustNotHaveHappened(); - } - [Fact] public void CanMap_ShouldReturnFalse_WhenInputIsNotValidType() { diff --git a/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/ActionClipboardCopyV1MapperTests.cs b/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/ActionClipboardCopyV1MapperTests.cs index bf876b36..ca308948 100644 --- a/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/ActionClipboardCopyV1MapperTests.cs +++ b/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/ActionClipboardCopyV1MapperTests.cs @@ -83,18 +83,6 @@ public void Ctor_ShouldThrowArgumentNullException_WhenAnArgumentIsNull() } } - [Fact] - public void CanHandleMultipleRepositories_ShouldBeFalse() - { - // arrange - - // act - var result = _sut.CanHandleMultipleRepositories(); - - // assert - result.Should().BeFalse(); - } - [Fact] public void CanMap_ShouldReturnFalse_WhenWrongType() { diff --git a/tests/RepoM.Plugin.Heidi.Tests/ActionProvider/ActionHeidiDatabasesV1MapperTests.cs b/tests/RepoM.Plugin.Heidi.Tests/ActionProvider/ActionHeidiDatabasesV1MapperTests.cs index 31638e35..815ffbe3 100644 --- a/tests/RepoM.Plugin.Heidi.Tests/ActionProvider/ActionHeidiDatabasesV1MapperTests.cs +++ b/tests/RepoM.Plugin.Heidi.Tests/ActionProvider/ActionHeidiDatabasesV1MapperTests.cs @@ -105,18 +105,6 @@ public void Ctor_ShouldThrowArgumentNullException_WhenAnArgumentIsNull() } } - [Fact] - public void CanHandleMultipleRepositories_ShouldBeFalse() - { - // arrange - - // act - var result = _sut.CanHandleMultipleRepositories(); - - // assert - result.Should().BeFalse(); - } - [Fact] public void CanMap_ShouldReturnFalse_WhenWrongType() { diff --git a/tests/RepoM.Plugin.SonarCloud.Tests/ActionSonarCloudV1MapperTests.cs b/tests/RepoM.Plugin.SonarCloud.Tests/ActionSonarCloudV1MapperTests.cs index b0e56581..0f962656 100644 --- a/tests/RepoM.Plugin.SonarCloud.Tests/ActionSonarCloudV1MapperTests.cs +++ b/tests/RepoM.Plugin.SonarCloud.Tests/ActionSonarCloudV1MapperTests.cs @@ -43,18 +43,6 @@ public void Ctor_ShouldThrow_WhenArgumentNull() act3.Should().Throw(); } - [Fact] - public void CanHandleMultipleRepositories_ShouldReturnFalse() - { - // arrange - - // act - var result = _sut.CanHandleMultipleRepositories(); - - // assert - result.Should().BeFalse(); - } - [Fact] public void CanMap_ShouldReturnFalse_WhenWrongType() {