Skip to content

Commit

Permalink
remove obsoletes (#135)
Browse files Browse the repository at this point in the history
* remove obsoletes

* fix sonar issue?

* update

* fix tests

* Docs changes

---------

Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
coenm and actions-user authored Aug 23, 2024
1 parent 1f3ebf3 commit e384db6
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 78 deletions.
2 changes: 1 addition & 1 deletion docs/RepoM.Plugin.Statistics.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ The following default configuration is used:

Properties:

- `PersistenceBuffer`: Timespan for buffered events before making them persistant (ie. `00:05:00` for five minutes). Must be greater then or equal to `00:00:10` (10 seconds).
- `PersistenceBuffer`: Timespan for buffered events before making them persistant (i.e. `00:05:00` for five minutes). Must be greater then or equal to `00:00:10` (10 seconds).
- `RetentionDays`: Number of days to keep statical information before deleting them. <!-- endInclude -->
10 changes: 1 addition & 9 deletions src/RepoM.Api/Common/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public sealed class AppSettings
[UiConfigured]
public bool PruneOnFetch { get; set; } = false;

[Obsolete("Will be removed in next version")]
public Size? MenuSize { get; set; }

/// <summary>
/// Preferred menu sizes of the RepoM. Will be set when window is resized.
/// </summary>
Expand All @@ -54,9 +51,6 @@ public sealed class AppSettings
[ManualConfigured]
public List<string> ReposRootDirectories { get; set; } = new();

[Obsolete("Will be removed in next version")]
public List<string>? EnabledSearchProviders { get; set; }

/// <summary>
/// List of plugins.
/// </summary>
Expand All @@ -67,12 +61,10 @@ public sealed class AppSettings
{
AutoFetchMode = AutoFetchMode.Off,
PruneOnFetch = false,
MenuSize = null,
ReposRootDirectories = new(),
EnabledSearchProviders = null,
Plugins = [],
PreferredMenuSizes = new(),
};
};
}

[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
Expand Down
16 changes: 0 additions & 16 deletions src/RepoM.Api/Common/FileAppSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ public bool PruneOnFetch
}
}

public double? MenuWidth => Settings.MenuSize?.Width;

public double? MenuHeight => Settings.MenuSize?.Height;

public void UpdateMenuSize(string resolution, MenuSize size)
{
Settings.PreferredMenuSizes[resolution] = new Size
Expand All @@ -153,8 +149,6 @@ public void UpdateMenuSize(string resolution, MenuSize size)
Width = size.MenuWidth,
};

Settings.MenuSize = null;

NotifyChange();
Save();
}
Expand Down Expand Up @@ -237,7 +231,6 @@ private void Save()

try
{
FixSettingsByRemovingObsoleteProps();
var jsonString = JsonConvert.SerializeObject(_settings, _jsonSerializationSettings);
_fileSystem.File.WriteAllText(file, jsonString);
}
Expand All @@ -247,15 +240,6 @@ private void Save()
}
}

[Obsolete("This fix will be removed when EnabledSearchProviders has been removed.")]
private void FixSettingsByRemovingObsoleteProps()
{
if (_settings != null)
{
_settings.EnabledSearchProviders = null;
}
}

private string GetFileName()
{
return Path.Combine(_appDataPathProvider.AppDataPath, "appsettings.json");
Expand Down
8 changes: 1 addition & 7 deletions src/RepoM.Api/Common/IAppSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ public interface IAppSettingsService

bool PruneOnFetch { get; set; }

[Obsolete("Will be removed in next version")]
double? MenuWidth { get; }

[Obsolete("Will be removed in next version")]
double? MenuHeight { get; }

void UpdateMenuSize(string resolution, MenuSize size);

bool TryGetMenuSize(string resolution, [NotNullWhen(true)] out MenuSize? size);
Expand All @@ -46,7 +40,7 @@ public interface IAppSettingsService
void RegisterInvalidationHandler(Action handler);
}

public struct MenuSize
public readonly struct MenuSize
{
public double MenuWidth { get; init; }

Expand Down
50 changes: 23 additions & 27 deletions src/RepoM.Api/Git/ProcessExecution/ProcessExecutingGitCommander.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public partial class ProcessExecutingGitCommander : IGitCommander
{
private readonly ILogger _logger;
private const string GIT_EXE = "git";

private const int GIT_PROCESS_TIMEOUT_MS = 10_000;

/// <summary>
/// Starting with version 1.7.10, Git uses UTF-8.
/// Use this encoding for Git input and output.
Expand Down Expand Up @@ -98,8 +99,6 @@ private static void RedirectStderr(ProcessStartInfo startInfo)

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

var psi = new ProcessStartInfo
{
FileName = GIT_EXE,
Expand All @@ -125,15 +124,7 @@ private static string Start(IRepository repository, string[] command, Action<Pro
{
if (e.Data == null)
{
try
{
outputWaitHandle.Set();
}
catch (ObjectDisposedException)
{
// if the wait handle was disposed,
// we can ignore the call to .Set()
}
TrySetAutoResetEvent(outputWaitHandle);
}
else
{
Expand All @@ -145,15 +136,7 @@ private static string Start(IRepository repository, string[] command, Action<Pro
{
if (e.Data == null)
{
try
{
errorWaitHandle.Set();
}
catch (ObjectDisposedException)
{
// if the wait handle was disposed,
// we can ignore the call to .Set()
}
TrySetAutoResetEvent(errorWaitHandle);
}
else
{
Expand All @@ -167,9 +150,9 @@ private static string Start(IRepository repository, string[] command, Action<Pro
process.BeginOutputReadLine();
process.BeginErrorReadLine();

if (process.WaitForExit(timeout) &&
outputWaitHandle.WaitOne(timeout) &&
errorWaitHandle.WaitOne(timeout))
if (process.WaitForExit(GIT_PROCESS_TIMEOUT_MS) &&
outputWaitHandle.WaitOne(GIT_PROCESS_TIMEOUT_MS) &&
errorWaitHandle.WaitOne(GIT_PROCESS_TIMEOUT_MS))
{
// Process completed. Check process.ExitCode here.
return output.ToString();
Expand All @@ -180,7 +163,7 @@ private static string Start(IRepository repository, string[] command, Action<Pro
}
finally
{
if (!process.WaitForExit((int)TimeSpan.FromSeconds(10).TotalMilliseconds))
if (!process.WaitForExit(GIT_PROCESS_TIMEOUT_MS))
{
throw new GitCommandException("Command did not terminate.");
}
Expand All @@ -201,12 +184,25 @@ private static string QuoteProcessArgument(string arg)
{
return arg.Contains(' ') ? "\"" + arg + "\"" : arg;
}

private static void AssertValidCommand(string[] command)
{
if (command.Length < 1 || !_validCommandName.IsMatch(command[0]))
{
throw new Exception("bad git command: " + (command.Length == 0 ? "" : command[0]));
throw new GitCommandException("bad git command: " + (command.Length == 0 ? "" : command[0]));
}
}

private static void TrySetAutoResetEvent(AutoResetEvent handle)
{
try
{
handle.Set();
}
catch (ObjectDisposedException)
{
// if the wait handle was disposed,
// we can ignore the call to .Set()
}
}

Expand Down
10 changes: 0 additions & 10 deletions src/RepoM.App/Services/WindowSizeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ public void Register()
}
else
{
if (_appSettings.MenuWidth is > 0)
{
_mainWindow.Width = _appSettings.MenuWidth.Value;
}

if (_appSettings.MenuHeight is > 0)
{
_mainWindow.Height = _appSettings.MenuHeight.Value;
}

_appSettings.UpdateMenuSize(
_currentResolution,
new MenuSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ namespace RepoM.Plugin.AzureDevOps.PersistentConfiguration;
public class AzureDevopsConfigV1
{
/// <summary>
/// Personal access token (PAT) to access Azure Devops. The PAT should be granted access to `todo` rights.
/// Personal access token (PAT) to access Azure Devops. The PAT should be granted access to read pull requests.
/// To create a PAT, goto `https://dev.azure.com/[my-organisation]/_usersSettings/tokens`.
/// </summary>
public string? PersonalAccessToken { get; init; }

/// <summary>
/// The base url of azure devops for your organisation (ie. `https://dev.azure.com/[my-organisation]/`).
/// The base url of azure devops for your organisation (i.e. `https://dev.azure.com/[my-organisation]/`).
/// </summary>
public string? BaseUrl { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace RepoM.Plugin.Statistics.PersistentConfiguration;
public class StatisticsConfigV1
{
/// <summary>
/// Timespan for buffered events before making them persistant (ie. `00:05:00` for five minutes). Must be greater then or equal to `00:00:10` (10 seconds).
/// Timespan for buffered events before making them persistant (i.e. `00:05:00` for five minutes). Must be greater then or equal to `00:00:10` (10 seconds).
/// </summary>
public TimeSpan? PersistenceBuffer { get; init; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Title will be the last part of the branchname split on `/`, so `feature/123-test
IsAction: false,
IsFunc: false,
IsConst: false,
Description: List of reviewer ids. The id should be a valid Azure DevOps user id (ie. GUID).
Description: List of reviewer ids. The id should be a valid Azure DevOps user id (i.e. GUID).
},
{
IsTemplate: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public string Type
public Text ToBranch { get; set; } = null!;

/// <summary>
/// List of reviewer ids. The id should be a valid Azure DevOps user id (ie. GUID).
/// List of reviewer ids. The id should be a valid Azure DevOps user id (i.e. GUID).
/// </summary>
public List<Text> ReviewerIds { get; set; } = new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ The following default configuration is used:

Properties:

- `PersonalAccessToken`: Personal access token (PAT) to access Azure Devops. The PAT should be granted access to `todo` rights.
- `PersonalAccessToken`: Personal access token (PAT) to access Azure Devops. The PAT should be granted access to read pull requests.
To create a PAT, goto `https://dev.azure.com/[my-organisation]/_usersSettings/tokens`.
- `BaseUrl`: The base url of azure devops for your organisation (ie. `https://dev.azure.com/[my-organisation]/`).
- `BaseUrl`: The base url of azure devops for your organisation (i.e. `https://dev.azure.com/[my-organisation]/`).
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ The following default configuration is used:

Properties:

- `PersistenceBuffer`: Timespan for buffered events before making them persistant (ie. `00:05:00` for five minutes). Must be greater then or equal to `00:00:10` (10 seconds).
- `PersistenceBuffer`: Timespan for buffered events before making them persistant (i.e. `00:05:00` for five minutes). Must be greater then or equal to `00:00:10` (10 seconds).
- `RetentionDays`: Number of days to keep statical information before deleting them.

0 comments on commit e384db6

Please sign in to comment.