Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup and documentation #67

Merged
merged 44 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a7890eb
Remove obsolete config
coenm Aug 12, 2023
1ee9424
Docs changes
actions-user Aug 12, 2023
41b9872
Update
coenm Aug 12, 2023
890e51e
Merge branch 'feature/cleanup-and-documentation' of https://github.co…
coenm Aug 12, 2023
e947f0d
Remove json test files
coenm Aug 12, 2023
23c2198
Remove json test files
coenm Aug 14, 2023
7e08d95
Update
coenm Aug 14, 2023
c434011
Cleanup
coenm Aug 14, 2023
14a7268
Cleanup
coenm Aug 14, 2023
a5a8b35
fix build
coenm Aug 14, 2023
dee4136
WIP documentation of comparers
coenm Aug 14, 2023
7d30859
Docs changes
actions-user Aug 14, 2023
b029c77
Fix
coenm Aug 14, 2023
bf6b36c
Merge branch 'feature/cleanup-and-documentation' of https://github.co…
coenm Aug 14, 2023
c2ec39d
Docs changes
actions-user Aug 14, 2023
ae5548e
update docs
coenm Aug 14, 2023
965b568
Merge branch 'feature/cleanup-and-documentation' of https://github.co…
coenm Aug 14, 2023
36b60f5
update
coenm Aug 14, 2023
a75d42c
Docs changes
actions-user Aug 14, 2023
5a02e3b
Rename compositon@1 to composition-comparer@1
coenm Aug 14, 2023
70ac542
Merge branch 'feature/cleanup-and-documentation' of https://github.co…
coenm Aug 14, 2023
92845ed
Docs changes
actions-user Aug 14, 2023
69fc6ce
..
coenm Aug 15, 2023
1359e8c
Merge branch 'feature/cleanup-and-documentation' of https://github.co…
coenm Aug 15, 2023
5daf5d2
Docs changes
actions-user Aug 15, 2023
665bdf5
UPdate
coenm Aug 15, 2023
e3d27a3
Merge branch 'feature/cleanup-and-documentation' of https://github.co…
coenm Aug 15, 2023
e9acb6f
Docs changes
actions-user Aug 15, 2023
27650a2
WIP #68 Copy template file to when file not exist. Partial remove js…
coenm Aug 15, 2023
4c2d42a
Merge branch 'feature/cleanup-and-documentation' of https://github.co…
coenm Aug 15, 2023
7f839de
cleanup
coenm Aug 15, 2023
5e2e356
cleanup
coenm Aug 15, 2023
b9aae05
cleanup
coenm Aug 15, 2023
278e253
update doc
coenm Aug 15, 2023
8349f13
cleanup
coenm Aug 15, 2023
4f993c9
Docs changes
actions-user Aug 15, 2023
4caf2f0
fix sonar issue
coenm Aug 15, 2023
f6d511a
sonar issues
coenm Aug 15, 2023
e2bcf9c
Merge branch 'feature/cleanup-and-documentation' of https://github.co…
coenm Aug 15, 2023
8f1f3c0
update docs
coenm Aug 15, 2023
3462a12
Docs changes
actions-user Aug 15, 2023
8f15eb9
Implement #68
coenm Aug 15, 2023
2446f03
Merge branch 'feature/cleanup-and-documentation' of https://github.co…
coenm Aug 15, 2023
60e4090
sonar issues
coenm Aug 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ The `RepositoryActions.yaml` file also contains a section to define tags per rep

## Ordering and Filtering

[Filtering](docs/Filtering.md) [Ordering](docs/Ordering.md)
The order of the repositories shown in RepoM is customizable. The default is alphabetical on the repository name. Read more about ordering [here](docs/Ordering.md).

The repositories shown in RepoM are filtered using the search box in RepoM. But the default set can also be configured using different presets. [This page](docs/Filtering.md) describes how to create custom filter presets.

## Global configuration

Expand Down
4 changes: 3 additions & 1 deletion README.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ The `RepositoryActions.yaml` file also contains a section to define tags per rep

## Ordering and Filtering

[Filtering](docs/Filtering.md) [Ordering](docs/Ordering.md)
The order of the repositories shown in RepoM is customizable. The default is alphabetical on the repository name. Read more about ordering [here](docs/Ordering.md).

The repositories shown in RepoM are filtered using the search box in RepoM. But the default set can also be configured using different presets. [This page](docs/Filtering.md) describes how to create custom filter presets.

## Global configuration

Expand Down
6 changes: 3 additions & 3 deletions _ref/RepoM.Sorting.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Work:
type: composition@1
type: composition-comparer@1
comparers:
- type: score-comparer@1
score-provider:
Expand All @@ -19,7 +19,7 @@ Work:
property: Name
weight: 1
Work Dynamic:
type: composition@1
type: composition-comparer@1
comparers:
- type: score-comparer@1
score-provider:
Expand Down Expand Up @@ -58,7 +58,7 @@ Work Dynamic:
property: Name
weight: 1
Prive:
type: composition@1
type: composition-comparer@1
comparers:
- type: score-comparer@1
score-provider:
Expand Down
97 changes: 96 additions & 1 deletion docs/Ordering.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,98 @@
# Ordering

todo.
The order of the repositories shown in RepoM is customizable. The default is alphabetical on the repository name.

Orderings are defined in yaml using repository-`comparers` and repository-`scorers`. You can switch at any given time between orderings using the hamburgermenu in RepoM.

## Definitions

A [`comparer`](#comparers) compares two repositories resulting in an order between the two. The comparison is defined by the type of comparer. It is possible to compare by repository name (assending order) or to compare repositories by the timestamp of the last action performed by RepoM.

[`Scorers`](#scorers) however calculate a score over exactly one repository. It does not compare repositories. Comparing repositories by score, use the `score-comparer@1`.

## Comparers

- [`az-comparer@1`](#az-comparer1)<!-- include: RepositoriesComparerConfigurationTests.CoreComparersMarkdown.verified.md -->
- [`composition-comparer@1`](#composition-comparer1)
- [`score-comparer@1`](#score-comparer1)
- [`sum-comparer@1`](#sum-comparer1)

These comparers are available by using the corresponding plugin.
- [`last-opened-comparer@1`](#last-opened-comparer1)

### `az-comparer@1`

Compares two repositories by a given property alphabetically in ascending order.<!-- include: RepositoriesComparerConfigurationTests.DocsRepositoriesComparerConfiguration_AlphabetComparerConfigurationV1.verified.md -->

Properties:

- `property`: Repository property. Currently, only `Name`, and `Location` are supported. Otherwise, comparison will always result in `0`. (optional)
- `weight`: The weight of this comparer. The higher the weight, the higher the impact.<!-- endInclude -->

### `composition-comparer@1`

Compares two repositories by a composition of comparers.<!-- include: RepositoriesComparerConfigurationTests.DocsRepositoriesComparerConfiguration_CompositionComparerConfigurationV1.verified.md -->

Properties:

- `comparers`: List of comparers. The first comparer not resulting in `0` will be used as final result.<!-- endInclude -->

### `score-comparer@1`

Compares two repositories by a repository score. The calculation of the repository score is defined in the score provider.<!-- include: RepositoriesComparerConfigurationTests.DocsRepositoriesComparerConfiguration_ScoreComparerConfigurationV1.verified.md -->

Properties:

- `score-provider`: The score provider to calculate a score for a repository. (optional)<!-- endInclude -->

### `sum-comparer@1`

Compares two repositories by the sum of the results of the comparers.<!-- include: RepositoriesComparerConfigurationTests.DocsRepositoriesComparerConfiguration_SumComparerConfigurationV1.verified.md -->

Properties:

- `comparers`: A list of comparers. The sum of the results of the comparers will be used as final result.<!-- endInclude -->

### `last-opened-comparer@1`

Compares two repositories by the timestamp of the last action RepoM performed on the repository.<!-- include: RepositoriesComparerConfigurationTests.DocsRepositoriesComparerConfiguration_LastOpenedConfigurationV1.verified.md -->

Properties:

- `weight`: The weight of this comparer. The higher the weight, the higher the impact.<!-- endInclude -->
<!-- endInclude -->

## Scorers

- [`is-pinned-scorer@1`](#is-pinned-scorer1)<!-- include: RepositoriesScorerConfigurationTests.CoreScorersMarkdown.verified.md -->
- [`tag-scorer@1`](#tag-scorer1)

These scorers are available by using the corresponding plugin.
- [`usage-scorer@1`](#usage-scorer1)

### `is-pinned-scorer@1`

Repository scorer based on the pinned state of a repository.<!-- include: RepositoriesScorerConfigurationTests.DocsRepositoriesScorerConfiguration_IsPinnedScorerConfigurationV1.verified.md -->

Properties:

- `weight`: The weight of this scorer. The higher the weight, the higher the impact.<!-- endInclude -->

### `tag-scorer@1`

Repository scorer based on the tags of a repository.<!-- include: RepositoriesScorerConfigurationTests.DocsRepositoriesScorerConfiguration_TagScorerConfigurationV1.verified.md -->

Properties:

- `weight`: The weight of this scorer. The higher the weight, the higher the impact.
- `tag`: The tag to match on. If the repository has this tag, the score will return the weight, otherwise, `0`. (optional)<!-- endInclude -->

### `usage-scorer@1`

Repository scorer based on it's usage by RepoM. The more it's used, the higher the score.<!-- include: RepositoriesScorerConfigurationTests.DocsRepositoriesScorerConfiguration_UsageScorerConfigurationV1.verified.md -->

Properties:

- `windows`: Specific 'windows' to calculate the score for.
- `max-score`: The maximum score a repository can get.<!-- endInclude -->
<!-- endInclude -->
2 changes: 1 addition & 1 deletion docs/RepoM.Plugin.Heidi.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Heidi

This module integrates with a portable [HeidiSQL](https://www.heidisql.com/) installation. The portable Heidi DB saves it's database configuration in a portable configuration file.
This module integrates with a portable [HeidiSQL](https://www.heidisql.com/) installation. The portable Heidi DB saves its database configuration in a portable configuration file.
This module monitors this file and provides an action menu and a variable provider to access this information.

To use this module, make sure it is enabled in RepoM by opening the menu and navigate to 'Plugins'. When enabling or disabling a plugin, you should restart RepoM.<!-- singleLineInclude: _plugin_enable. path: /docs/mdsource/_plugin_enable.include.md -->
Expand Down
4 changes: 0 additions & 4 deletions docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ This is the default configuration.
},
"ReposRootDirectories": [],
"EnabledSearchProviders": [],
"SonarCloudPersonalAccessToken": null,
"AzureDevOps": null,
"Plugins": []
}
```
Expand All @@ -38,6 +36,4 @@ Properties:<!-- include: DocsAppSettingsTests.AppSettingsDocumentationGeneration
- `MenuSize`: The menu size of RepoM. This is set when the window is resized. (optional, UI configured)
- `ReposRootDirectories`: List of root directories where RepoM will search for git repositories. If null or empty, all fixed drives will be searched from the root. (optional, Manual configured)
- `EnabledSearchProviders`: List of search providers. Search providers can be added by plugins. (optional, UI configured)
- `SonarCloudPersonalAccessToken`: SonarCloud PAT. (<span style="color: red;">Obsolete, moved to plugin config</span>)
- `AzureDevOps`: Azure DevOps config. (<span style="color: red;">Obsolete, moved to plugin config</span>)
- `Plugins`: List of plugins. (optional, UI configured)<!-- endInclude -->
18 changes: 17 additions & 1 deletion docs/mdsource/Ordering.source.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Ordering

todo.
The order of the repositories shown in RepoM is customizable. The default is alphabetical on the repository name.

Orderings are defined in yaml using repository-`comparers` and repository-`scorers`. You can switch at any given time between orderings using the hamburgermenu in RepoM.

## Definitions

A [`comparer`](#comparers) compares two repositories resulting in an order between the two. The comparison is defined by the type of comparer. It is possible to compare by repository name (assending order) or to compare repositories by the timestamp of the last action performed by RepoM.

[`Scorers`](#scorers) however calculate a score over exactly one repository. It does not compare repositories. Comparing repositories by score, use the `score-comparer@1`.

## Comparers

include: RepositoriesComparerConfigurationTests.CoreComparersMarkdown.verified.md

## Scorers

include: RepositoriesScorerConfigurationTests.CoreScorersMarkdown.verified.md
2 changes: 1 addition & 1 deletion docs/mdsource/RepoM.Plugin.Heidi.source.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Heidi

This module integrates with a portable [HeidiSQL](https://www.heidisql.com/) installation. The portable Heidi DB saves it's database configuration in a portable configuration file.
This module integrates with a portable [HeidiSQL](https://www.heidisql.com/) installation. The portable Heidi DB saves its database configuration in a portable configuration file.
This module monitors this file and provides an action menu and a variable provider to access this information.

include: _plugin_enable
Expand Down
42 changes: 42 additions & 0 deletions src/RepoM.Api/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace RepoM.Api;
using System.Threading.Tasks;
using System;
using RepoM.Api.Plugins.SimpleInjector;
using RepoM.Core.Plugin;
using RepoM.Core.Plugin.Common;
using RepoM.Core.Plugin.RepositoryOrdering.Configuration;

public class CoreBootstrapper
{
Expand All @@ -21,6 +23,8 @@ public class CoreBootstrapper
private readonly IAppDataPathProvider _appDataProvider;
private readonly ILoggerFactory _loggerFactory;

private static readonly Assembly _thisAssembly = typeof(CoreBootstrapper).Assembly;

public CoreBootstrapper(IPluginFinder pluginFinder, IFileSystem fileSystem, IAppDataPathProvider appDataProvider, ILoggerFactory loggerFactory)
{
_pluginFinder = pluginFinder ?? throw new ArgumentNullException(nameof(pluginFinder));
Expand All @@ -29,6 +33,22 @@ public CoreBootstrapper(IPluginFinder pluginFinder, IFileSystem fileSystem, IApp
_loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
}

public static void RegisterRepositoryScorerConfigurationsTypes(Container container)
{
foreach (Type type in GetNonAbstractNonGenericInheritedExportedTypesFrom<IRepositoryScorerConfiguration>(_thisAssembly))
{
container.RegisterScorerConfigurationForType(type);
}
}

public static void RegisterRepositoryComparerConfigurationsTypes(Container container)
{
foreach (Type type in GetNonAbstractNonGenericInheritedExportedTypesFrom<IRepositoriesComparerConfiguration>(_thisAssembly))
{
container.RegisterComparerConfigurationForType(type);
}
}

public async Task LoadAndRegisterPluginsAsync(Container container, string baseDirectory)
{
_ = container ?? throw new ArgumentNullException(nameof(container));
Expand Down Expand Up @@ -79,4 +99,26 @@ private static PluginSettings ConvertToPluginSettings(PluginInfo pluginInfo, str
{
return new PluginSettings(pluginInfo.Name, pluginInfo.AssemblyPath.Replace(baseDir, string.Empty), enabled);
}

static IEnumerable<Type> GetExportedTypesFrom(Assembly assembly)
{
try
{
return assembly.DefinedTypes.Select(info => info.AsType());
}
catch (NotSupportedException)
{
// A type load exception would typically happen on an Anonymously Hosted DynamicMethods
// Assembly and it would be safe to skip this exception.
return Enumerable.Empty<Type>();
}
}

static IEnumerable<Type> GetNonAbstractNonGenericInheritedExportedTypesFrom<T>(Assembly assembly)
{
return GetExportedTypesFrom(assembly)
.Where(t => typeof(T).GetTypeInfo().IsAssignableFrom(t.GetTypeInfo()))
.Where(t => t.GetTypeInfo() is { IsAbstract: false, IsGenericTypeDefinition: false, });

}
}
36 changes: 3 additions & 33 deletions src/RepoM.Api/Common/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ public sealed class AppSettings
[UiConfigured]
public List<string> EnabledSearchProviders { get; set; } = new();

/// <summary>
/// SonarCloud PAT.
/// </summary>
[Obsolete("This is done using plugin.")]
public string? SonarCloudPersonalAccessToken { get; set; } = string.Empty;

/// <summary>
/// Azure DevOps config.
/// </summary>
[Obsolete("This is done using plugin.")]
public AzureDevOpsOptions? AzureDevOps { get; set; } = AzureDevOpsOptions.Default;

/// <summary>
/// List of plugins.
/// </summary>
Expand All @@ -82,8 +70,6 @@ public sealed class AppSettings
MenuSize = Size.Default,
ReposRootDirectories = new(),
EnabledSearchProviders = new List<string>(1),
SonarCloudPersonalAccessToken = null,
AzureDevOps = AzureDevOpsOptions.Default,
Plugins = new List<PluginOptions>(),
};
}
Expand All @@ -94,15 +80,6 @@ public sealed class UiConfiguredAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public sealed class ManualConfiguredAttribute : Attribute { }

public class AzureDevOpsOptions
{
public string? PersonalAccessToken { get; set; } = string.Empty;

public string? BaseUrl { get; set; } = string.Empty;

public static AzureDevOpsOptions? Default => null;
}

public class Size
{
public double Height { get; set; }
Expand All @@ -118,16 +95,9 @@ public class Size

public class PluginOptions
{
public PluginOptions()
{
Name = string.Empty;
DllName = string.Empty;
Enabled = false;
}

public string Name { get; init; }
public string Name { get; init; } = string.Empty;

public string DllName { get; init; }
public string DllName { get; init; } = string.Empty;

public bool Enabled { get; init; }
public bool Enabled { get; init; } = false;
}
Loading
Loading