Skip to content

Commit

Permalink
Fix file formattings
Browse files Browse the repository at this point in the history
  • Loading branch information
Waescher, Andreas committed Jan 2, 2021
1 parent c324066 commit 41853aa
Show file tree
Hide file tree
Showing 29 changed files with 475 additions and 514 deletions.
40 changes: 20 additions & 20 deletions RepoZ.Api.Common/Common/FileAppSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ namespace RepoZ.Api.Common.Common
{
public class FileAppSettingsService : IAppSettingsService
{
private AppSettings _settings;
private readonly List<Action> _invalidationHandlers = new List<Action>();
private AppSettings _settings;
private readonly List<Action> _invalidationHandlers = new List<Action>();

public FileAppSettingsService(IAppDataPathProvider appDataPathProvider)
public FileAppSettingsService(IAppDataPathProvider appDataPathProvider)
{
AppDataPathProvider = appDataPathProvider ?? throw new ArgumentNullException(nameof(appDataPathProvider));
}

private AppSettings Load()
private AppSettings Load()
{
string file = GetFileName();

Expand Down Expand Up @@ -49,7 +49,7 @@ private void Save()
catch { /* Our app settings are not critical. For our purposes, we want to ignore IO exceptions */ }
}

private string GetFileName() => Path.Combine(AppDataPathProvider.GetAppDataPath(), "appsettings.json");
private string GetFileName() => Path.Combine(AppDataPathProvider.GetAppDataPath(), "appsettings.json");

public IAppDataPathProvider AppDataPathProvider { get; }

Expand All @@ -69,25 +69,25 @@ public AutoFetchMode AutoFetchMode
get => Settings.AutoFetchMode;
set
{
if (value != Settings.AutoFetchMode)
{
Settings.AutoFetchMode = value;
if (value != Settings.AutoFetchMode)
{
Settings.AutoFetchMode = value;

NotifyChange();
Save();
}
NotifyChange();
Save();
}
}
}

public void RegisterInvalidationHandler(Action handler)
{
_invalidationHandlers.Add(handler);
}
public void RegisterInvalidationHandler(Action handler)
{
_invalidationHandlers.Add(handler);
}

public void NotifyChange()
{
_invalidationHandlers.ForEach(h => h.Invoke());
}
public void NotifyChange()
{
_invalidationHandlers.ForEach(h => h.Invoke());
}

}
}
}
2 changes: 1 addition & 1 deletion RepoZ.Api.Common/Common/IAppSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public interface IAppSettingsService
{
AutoFetchMode AutoFetchMode { get; set; }

void RegisterInvalidationHandler(Action handler);
void RegisterInvalidationHandler(Action handler);
}
}
10 changes: 3 additions & 7 deletions RepoZ.Api.Common/Common/ITranslationService.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace RepoZ.Api.Common.Common
namespace RepoZ.Api.Common.Common
{
public interface ITranslationService
{
string Translate(string value);
string Translate(string value, params object[] args);
}
string Translate(string value, params object[] args);
}
}
50 changes: 25 additions & 25 deletions RepoZ.Api.Common/Git/AutoFetch/DefaultAutoFetchHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

namespace RepoZ.Api.Common.Git.AutoFetch
{
public class DefaultAutoFetchHandler : IAutoFetchHandler
{
private bool _active;
private AutoFetchMode? _mode = null;
public class DefaultAutoFetchHandler : IAutoFetchHandler
{
private bool _active;
private AutoFetchMode? _mode = null;
private readonly Timer _timer;
private readonly Dictionary<AutoFetchMode, AutoFetchProfile> _profiles;
private int _lastFetchRepository = -1;

public DefaultAutoFetchHandler(IAppSettingsService appSettingsService,
public DefaultAutoFetchHandler(IAppSettingsService appSettingsService,
IRepositoryInformationAggregator repositoryInformationAggregator,
IRepositoryWriter repositoryWriter)
{
AppSettingsService = appSettingsService ?? throw new ArgumentNullException(nameof(appSettingsService));
{
AppSettingsService = appSettingsService ?? throw new ArgumentNullException(nameof(appSettingsService));
RepositoryInformationAggregator = repositoryInformationAggregator ?? throw new ArgumentNullException(nameof(repositoryInformationAggregator));
RepositoryWriter = repositoryWriter ?? throw new ArgumentNullException(nameof(repositoryWriter));
AppSettingsService.RegisterInvalidationHandler(() => Mode = AppSettingsService.AutoFetchMode);
Expand Down Expand Up @@ -99,34 +99,34 @@ private void FetchNext(object timerState)
}
}

public bool Active
{
get => _active;
set
{
_active = value;
public bool Active
{
get => _active;
set
{
_active = value;

if (value && _mode == null)
Mode = AppSettingsService.AutoFetchMode;
Mode = AppSettingsService.AutoFetchMode;

UpdateBehavior();
}
}
}

public AutoFetchMode Mode
{
get => _mode ?? AutoFetchMode.Off;
set
{
if (value == _mode)
return;
public AutoFetchMode Mode
{
get => _mode ?? AutoFetchMode.Off;
set
{
if (value == _mode)
return;

_mode = value;
Console.WriteLine("Auto fetch is: " + _mode.GetValueOrDefault().ToString());

UpdateBehavior();
}
}
UpdateBehavior();
}
}

public IAppSettingsService AppSettingsService { get; }

Expand Down
8 changes: 4 additions & 4 deletions RepoZ.Api.Common/Git/AutoFetch/IAutoFetchHandler.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace RepoZ.Api.Common.Git.AutoFetch
{
public interface IAutoFetchHandler
{
bool Active { get; set; }
}
public interface IAutoFetchHandler
{
bool Active { get; set; }
}
}
3 changes: 1 addition & 2 deletions RepoZ.Api.Common/Git/ProcessExecution/GitCommandException.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System;
using System.Diagnostics;

namespace RepoZ.Api.Common.Git.ProcessExecution
{
public class GitCommandException : Exception
{
public GitCommandException() : base()
public GitCommandException() : base()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ protected virtual string Start(Api.Git.Repository repository, string[] command,
var error = new StringBuilder();

using (var outputWaitHandle = new AutoResetEvent(initialState: false))
using (var errorWaitHandle = new AutoResetEvent(initialState: false))
using (var process = new Process())
using (var errorWaitHandle = new AutoResetEvent(initialState: false))
using (var process = new Process())
{
process.StartInfo = psi;

Expand Down
26 changes: 13 additions & 13 deletions RepoZ.Api.Win/Git/WindowsRepositoryActionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public RepositoryAction GetSecondaryAction(Repository repository)
return CreateProcessRunnerAction(_translationService.Translate("Open in Windows PowerShell"), "powershell.exe ", $"-executionpolicy bypass -noexit -command \"Set-Location '{repository.SafePath}'\"");
}

public IEnumerable<RepositoryAction> GetContextMenuActions(IEnumerable<Repository> repositories)
{
return GetContextMenuActionsInternal(repositories.Where(r => Directory.Exists(r.SafePath))).Where(a => a != null);
}
public IEnumerable<RepositoryAction> GetContextMenuActions(IEnumerable<Repository> repositories)
{
return GetContextMenuActionsInternal(repositories.Where(r => Directory.Exists(r.SafePath))).Where(a => a != null);
}

private IEnumerable<RepositoryAction> GetContextMenuActionsInternal(IEnumerable<Repository> repositories)
{
Expand Down Expand Up @@ -84,15 +84,15 @@ private IEnumerable<RepositoryAction> GetContextMenuActionsInternal(IEnumerable<
yield return new RepositoryAction()
{
Name = _translationService.Translate("Checkout"),
DeferredSubActionsEnumerator =() => singleRepository.LocalBranches
.Take(50)
.Select(branch => new RepositoryAction()
{
Name = branch,
Action = (_, __) => _repositoryWriter.Checkout(singleRepository, branch),
CanExecute = !singleRepository.CurrentBranch.Equals(branch, StringComparison.OrdinalIgnoreCase)
})
.ToArray()
DeferredSubActionsEnumerator = () => singleRepository.LocalBranches
.Take(50)
.Select(branch => new RepositoryAction()
{
Name = branch,
Action = (_, __) => _repositoryWriter.Checkout(singleRepository, branch),
CanExecute = !singleRepository.CurrentBranch.Equals(branch, StringComparison.OrdinalIgnoreCase)
})
.ToArray()
};
}

Expand Down
2 changes: 1 addition & 1 deletion RepoZ.Api.Win/PInvoke/Combridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public T GetPropertyValue<T>(string propertyName)
/// <param name="flags">The binding flags to decide whether to invoke methods or to retrieve property values.</param>
/// <returns></returns>
protected T GetValueViaReflection<T>(string memberName, BindingFlags flags)
=> (T)_comType.Value.InvokeMember(memberName, flags, null, ComObject, null);
=> (T)_comType.Value.InvokeMember(memberName, flags, null, ComObject, null);

/// <summary>
/// Gets the wrapped COM object for native access.
Expand Down
10 changes: 4 additions & 6 deletions RepoZ.Api/Git/DefaultRepositoryInformationAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RepoZ.Api.Git
{
Expand Down Expand Up @@ -79,10 +77,10 @@ public bool HasRepository(string path)
return GetRepositoryByPath(path) != null;
}

public void Reset()
{
_dataSource.Clear();
}
public void Reset()
{
_dataSource.Clear();
}

public ObservableCollection<RepositoryView> Repositories => _dataSource;
}
Expand Down
12 changes: 4 additions & 8 deletions RepoZ.Api/Git/IRepositoryActionProvider.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace RepoZ.Api.Git
{
public interface IRepositoryActionProvider
{
RepositoryAction GetPrimaryAction(Repository repository);
RepositoryAction GetPrimaryAction(Repository repository);

RepositoryAction GetSecondaryAction(Repository repository);
RepositoryAction GetSecondaryAction(Repository repository);

IEnumerable<RepositoryAction> GetContextMenuActions(IEnumerable<Repository> repositories);
IEnumerable<RepositoryAction> GetContextMenuActions(IEnumerable<Repository> repositories);
}
}
5 changes: 2 additions & 3 deletions RepoZ.Api/Git/IRepositoryInformationAggregator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.ObjectModel;

namespace RepoZ.Api.Git
{
Expand All @@ -13,7 +12,7 @@ public interface IRepositoryInformationAggregator

ObservableCollection<RepositoryView> Repositories { get; }

void Reset();
void Reset();

bool HasRepository(string path);
}
Expand Down
4 changes: 2 additions & 2 deletions RepoZ.Api/Git/IRepositoryMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ public interface IRepositoryMonitor

event EventHandler<string> OnDeletionDetected;

event EventHandler<bool> OnScanStateChanged;
event EventHandler<bool> OnScanStateChanged;

void Stop();

void Observe();

void Reset();
void Reset();

Task ScanForLocalRepositoriesAsync();

Expand Down
6 changes: 1 addition & 5 deletions RepoZ.Api/Git/IRepositoryObserver.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RepoZ.Api.Git
{
public interface IRepositoryObserver : IDisposable
public interface IRepositoryObserver : IDisposable
{
void Setup(Repository repository, int detectionToAlertDelayMilliseconds);

Expand Down
19 changes: 7 additions & 12 deletions RepoZ.Api/Git/StatusCompressor.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RepoZ.Api.Git;
using System.Text;

namespace RepoZ.Api.Git
{
Expand Down Expand Up @@ -45,14 +40,14 @@ public string Compress(Repository repository)
else
{
if (isBehind)
builder.Append($"{_statusCharacterMap.ArrowDownSign}{repository.BehindBy.Value}");
builder.Append($"{_statusCharacterMap.ArrowDownSign}{repository.BehindBy.Value}");

if (isAhead)
{
if (isBehind)
builder.Append(" ");
if (isAhead)
{
if (isBehind)
builder.Append(" ");

builder.Append($"{_statusCharacterMap.ArrowUpSign}{repository.AheadBy.Value}");
builder.Append($"{_statusCharacterMap.ArrowUpSign}{repository.AheadBy.Value}");
}
}
}
Expand Down
Loading

0 comments on commit 41853aa

Please sign in to comment.