Skip to content

Commit

Permalink
and removing unused method from interface
Browse files Browse the repository at this point in the history
  • Loading branch information
coenm committed Aug 29, 2023
1 parent 2bee33e commit bc8b969
Show file tree
Hide file tree
Showing 34 changed files with 23 additions and 218 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/// <summary>
/// Starting with version 1.7.10, Git uses UTF-8.
/// Use this encoding for Git input and output.
Expand Down Expand Up @@ -108,13 +111,13 @@ private static void RedirectStderr(ProcessStartInfo startInfo)
startInfo.StandardErrorEncoding = _encoding;
}

private static string Start(Repository repository, string[] command, Action<ProcessStartInfo> initialize)
private static string Start(IRepository repository, string[] command, Action<ProcessStartInfo> initialize)
{
var timeout = (int)TimeSpan.FromSeconds(10).TotalMilliseconds;

var psi = new ProcessStartInfo
{
FileName = "git",
FileName = GIT_EXE,
WorkingDirectory = repository.Path,
};

Expand Down
3 changes: 2 additions & 1 deletion src/RepoM.Api/Git/RepositoryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<TagViewModel>();
public TagViewModel[] Tags { get; }

public override int GetHashCode()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action)
return action is RepositoryActionAssociateFileV1;
}

public bool CanHandleMultipleRepositories()
{
return false;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionAssociateFileV1, repository.First());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ bool IActionToRepositoryActionMapper.CanMap(Data.RepositoryAction action)
return action is RepositoryActionBrowseRepositoryV1;
}

bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories()
{
return false;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(Data.RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionBrowseRepositoryV1, repository.First());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ bool IActionToRepositoryActionMapper.CanMap(Data.RepositoryAction action)
return action is RepositoryActionBrowserV1;
}

bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories()
{
return false;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(Data.RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionBrowserV1, repository.First());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action)
return action is RepositoryActionCommandV1;
}

bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories()
{
return false;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionCommandV1, repository.First());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action)
return action is RepositoryActionExecutableV1;
}

bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories()
{
return false;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionExecutableV1, repository.First());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action)
return action is RepositoryActionFolderV1;
}

bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories()
{
return false;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionFolderV1, repository.First(), actionMapperComposition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action)
return action is RepositoryActionForEachV1;
}

bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories()
{
return false;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionForEachV1, repository.First(), actionMapperComposition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action)
return action is RepositoryActionGitCheckoutV1;
}

bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories()
{
return false;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionGitCheckoutV1, repository.First());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action)
return action is RepositoryActionGitFetchV1;
}

bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories()
{
return true;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> repositories, ActionMapperComposition actionMapperComposition)
{
Repository[] repos = repositories as Repository[] ?? repositories.ToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action)
return action is RepositoryActionGitPullV1;
}

bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories()
IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return true;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action)
return action is RepositoryActionGitPushV1;
}

bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories()
{
return true;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> repositories, ActionMapperComposition actionMapperComposition)
{
Repository[] repos = repositories as Repository[] ?? repositories.ToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ bool IActionToRepositoryActionMapper.CanMap(Data.RepositoryAction action)
return action is RepositoryActionIgnoreRepositoryV1;
}

bool IActionToRepositoryActionMapper.CanHandleMultipleRepositories()
{
return true;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(Data.RepositoryAction action, IEnumerable<Repository> repositories, ActionMapperComposition actionMapperComposition)
{
Repository[] repos = repositories as Repository[] ?? repositories.ToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action)
return action is RepositoryActionJustTextV1;
}

public bool CanHandleMultipleRepositories()
{
return false;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionJustTextV1, repository.First());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ActionMapperComposition
public ActionMapperComposition(IEnumerable<IActionToRepositoryActionMapper> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action)
return action is RepositoryActionPinRepositoryV1;
}

public bool CanHandleMultipleRepositories()
{
return true;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
foreach (Repository r in repository)
Expand Down Expand Up @@ -76,12 +71,12 @@ private IEnumerable<RepositoryActionBase> 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)
Expand All @@ -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(),
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action)
return action is RepositoryActionSeparatorV1;
}

public bool CanHandleMultipleRepositories()
{
return true;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
foreach (Repository r in repository)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public sealed class RepositoryActionPinRepositoryV1 : RepositoryAction
/// </summary>
public enum PinMode
{
// when deserialization fails, this is the value.
Unknown,

/// <summary>
/// Toggle
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ public interface IActionToRepositoryActionMapper
{
bool CanMap(RepositoryAction action);

bool CanHandleMultipleRepositories();

IEnumerable<RepositoryActionBase> Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition);
}
6 changes: 3 additions & 3 deletions src/RepoM.App/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ namespace RepoM.App;
/// </summary>
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;
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public bool CanMap(RepositoryAction action)
return action is RepositoryActionAzureDevOpsCreatePullRequestsV1;
}

public bool CanHandleMultipleRepositories()
{
return false;
}

public IEnumerable<RepositoryActionBase> Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionAzureDevOpsCreatePullRequestsV1, repository.First());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ public bool CanMap(RepositoryAction action)
return action is RepositoryActionAzureDevOpsGetPullRequestsV1;
}

public bool CanHandleMultipleRepositories()
{
return false;
}

public IEnumerable<RepositoryActionBase> Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionAzureDevOpsGetPullRequestsV1, repository.First());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ public bool CanMap(RepositoryAction action)
return action is RepositoryActionClipboardCopyV1;
}

public bool CanHandleMultipleRepositories()
{
return false;
}

public IEnumerable<RepositoryActionBase> Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionClipboardCopyV1, repository.First());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ public bool CanMap(RepositoryAction action)
return action is RepositoryActionHeidiDatabasesV1;
}

public bool CanHandleMultipleRepositories()
{
return false;
}

public IEnumerable<RepositoryActionBase> Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionHeidiDatabasesV1, repository.First());
Expand Down
5 changes: 0 additions & 5 deletions src/RepoM.Plugin.SonarCloud/ActionSonarCloudV1Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action)
return action is RepositoryActionSonarCloudSetFavoriteV1;
}

public bool CanHandleMultipleRepositories()
{
return false;
}

IEnumerable<RepositoryActionBase> IActionToRepositoryActionMapper.Map(RepositoryAction action, IEnumerable<Repository> repository, ActionMapperComposition actionMapperComposition)
{
return Map(action as RepositoryActionSonarCloudSetFavoriteV1, repository.First());
Expand Down
Loading

0 comments on commit bc8b969

Please sign in to comment.