Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="Broslyn" Version="1.2.0" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.7.8" />
<PackageReference Include="MSBuild.StructuredLogger" Version="2.2.291" />
<PackageReference Include="MSBuild.StructuredLogger" Version="2.2.337" />
<PackageReference Include="Scriban" Version="5.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace RepoM.ActionMenu.Core.ActionMenu.Model.ActionMenus.BrowseRepository;
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
using RepoM.ActionMenu.Core.Model;
using RepoM.ActionMenu.Interface.ActionMenuFactory;
using RepoM.ActionMenu.Interface.UserInterface;
using RepoM.ActionMenu.Interface.YamlModel;
Expand All @@ -21,25 +20,28 @@ protected override async IAsyncEnumerable<UserInterfaceRepositoryActionBase> Map
yield break;
}

var name = await context.RenderStringAsync(action.Name).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(name))
{
name = "Browse remote";
}
string menuTitle;
//var menuTitle = await context.RenderStringAsync(action.Name).ConfigureAwait(false);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this is commented

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's no longer gettng that text that way. It's getting it in a different way, depending on whether there is one or more remotes. See lines 32-52.

//if (string.IsNullOrWhiteSpace(menuTitle))
//{
// menuTitle = "Github: ";
//}

var forceSingle = await action.FirstOnly.EvaluateAsync(context).ConfigureAwait(false);

if (repository.Remotes.Count == 1 || forceSingle)
{
yield return new UserInterfaceRepositoryAction(name, repository)
menuTitle = TryGet_RemoteRepoLongName(repository.Remotes[0].Url);
yield return new UserInterfaceRepositoryAction(menuTitle, repository)
{
RepositoryCommand = new BrowseRepositoryCommand(repository.Remotes[0].Url),
};
}
else
{
menuTitle = "Remote repos";
yield return new DeferredSubActionsUserInterfaceRepositoryAction(
name,
menuTitle,
repository,
context,
captureScope: false,
Expand All @@ -50,14 +52,27 @@ protected override async IAsyncEnumerable<UserInterfaceRepositoryActionBase> Map
}
}

private static string TryGet_RemoteRepoLongName(string remoteUrl)
{
var splitString = remoteUrl.Trim().Split('/');
if (splitString.Length < 2)
{
return remoteUrl;
}

var name = splitString.Last().Replace(".git", "");
var author = splitString[^2];
return $"{author}/{name}";
}

private static Task<UserInterfaceRepositoryActionBase[]> EnumerateRemotes(IRepository repository)
{
return Task.FromResult(repository.Remotes
.Take(50)
.Select(remote => new UserInterfaceRepositoryAction(remote.Name, repository)
{
RepositoryCommand = new BrowseRepositoryCommand(remote.Url),
})
.Select(remote => new UserInterfaceRepositoryAction(TryGet_RemoteRepoLongName(remote.Url), repository)
{
RepositoryCommand = new BrowseRepositoryCommand(remote.Url),
})
.Cast<UserInterfaceRepositoryActionBase>()
.ToArray());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace RepoM.ActionMenu.Core.ActionMenu.Model.ActionMenus.Pin;
using RepoM.ActionMenu.Interface.YamlModel.Templating;

/// <summary>
/// Action to pin (or unpin) the current repository. Pinning is not persistant and all pinned repositories will be cleared when RepoM exits.
/// Action to pin (or unpin) the current repository. Pinning is not persistent and all pinned repositories will be cleared when RepoM exits.
/// Pinning a repository allowed custom filtering, ordering and searching.
/// </summary>
[RepositoryAction(TYPE_VALUE)]
Expand All @@ -21,7 +21,7 @@ public string Type
}

/// <inheritdoc cref="IName.Name"/>
[Text("(Un)Pin repository")]
[Text("Pin / Unpin Repo")]
public Text Name { get; set; } = null!;

/// <inheritdoc cref="IMenuAction.Active"/>
Expand All @@ -34,7 +34,7 @@ public string Type
/// <summary>
/// The pin mode `[Toggle, Pin, UnPin]`.
/// </summary>
public PinMode? Mode { get; set; } // GitHub issue: https://github.com/coenm/RepoM/issues/87
public PinMode? Mode { get; set; } = PinMode.Toggle; // GitHub issue: https://github.com/coenm/RepoM/issues/87

public override string ToString()
{
Expand Down
26 changes: 13 additions & 13 deletions src/RepoM.Api/Bootstrapper.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
namespace RepoM.Api;

using Microsoft.Extensions.Logging;
using RepoM.Api.Common;
using RepoM.Api.IO;
using RepoM.Api.Plugins;
using SimpleInjector;
using System;
using System.Collections.Generic;
using System.IO.Abstractions;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System;
using Microsoft.Extensions.Logging;
using RepoM.Api.Common;
using RepoM.Api.IO;
using RepoM.Api.Plugins;
using RepoM.Api.Plugins.SimpleInjector;
using RepoM.Core.Plugin;
using RepoM.Core.Plugin.Common;
using RepoM.Core.Plugin.RepositoryOrdering.Configuration;
using SimpleInjector;

public class CoreBootstrapper
{
private readonly IPluginFinder _pluginFinder;
private readonly IFileSystem _fileSystem;
private readonly IPluginFinder _pluginFinder;
private readonly IFileSystem _fileSystem;
private readonly IAppDataPathProvider _appDataProvider;
private readonly ILoggerFactory _loggerFactory;
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));
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
_pluginFinder = pluginFinder ?? throw new ArgumentNullException(nameof(pluginFinder));
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
_appDataProvider = appDataProvider ?? throw new ArgumentNullException(nameof(appDataProvider));
_loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
_loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
}

public static void RegisterRepositoryScorerConfigurationsTypes(Container container)
{
foreach (Type type in GetNonAbstractNonGenericInheritedExportedTypesFrom<IRepositoryScorerConfiguration>(_thisAssembly))
Expand Down
4 changes: 2 additions & 2 deletions src/RepoM.Api/EnsureStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace RepoM.Api;

public class EnsureStartup
{
private readonly IFileSystem _fileSystem;
private readonly IFileSystem _fileSystem;
private readonly IAppDataPathProvider _appDataProvider;

public EnsureStartup(IFileSystem fileSystem, IAppDataPathProvider appDataProvider)
{
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
_appDataProvider = appDataProvider ?? throw new ArgumentNullException(nameof(appDataProvider));
}

Expand Down
4 changes: 2 additions & 2 deletions src/RepoM.Api/Git/DefaultRepositoryMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public DefaultRepositoryMonitor(
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_autoFetchHandler = autoFetchHandler ?? throw new ArgumentNullException(nameof(autoFetchHandler));
_repositoryObservers = new Dictionary<string, IRepositoryObserver>();
_repositoryObservers = [];
_storeFlushTimer = new Timer(RepositoryStoreFlushTimerCallback, null, Timeout.Infinite, Timeout.Infinite);
}

Expand Down Expand Up @@ -153,7 +153,7 @@ private void ObserveRepositoryChanges()
{
_logger.LogTrace("ObserveRepositoryChanges start");

_detectors = new List<IRepositoryDetector>();
_detectors = [];

foreach (var path in _pathProvider.GetPaths())
{
Expand Down
18 changes: 9 additions & 9 deletions src/RepoM.Api/Resources/RepoM.Filtering.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Private:
name: Private
description: Private repositories
always-visible:
kind: query@1
query: RepoM OR is:pinned
filter:
kind: query@1
query: tag:private
Work:
name: Work
description: Work filtering
Expand All @@ -7,12 +16,3 @@ Work:
filter:
kind: query@1
query: tag:work
Private:
name: Private
description: Private repositories
always-visible:
kind: query@1
query: RepoM OR is:pinned
filter:
kind: query@1
query: (-tag:work OR tag:private)
61 changes: 28 additions & 33 deletions src/RepoM.Api/Resources/RepoM.Sorting.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,12 @@
Work:
type: composition-comparer@1
comparers:
- type: score-comparer@1
score-provider:
type: is-pinned-scorer@1
weight: 1
- type: score-comparer@1
score-provider:
type: tag-scorer@1
weight: 1
tag: Team1
- type: score-comparer@1
score-provider:
type: tag-scorer@1
weight: 1
tag: Work
- type: az-comparer@1
property: Name
weight: 1
Work Dynamic:
Most Active:
type: composition-comparer@1
comparers:
- type: score-comparer@1
score-provider:
type: is-pinned-scorer@1
weight: 1
- type: score-comparer@1
score-provider:
type: tag-scorer@1
weight: 1
tag: Team1
weight: 40
- type: last-opened-comparer@1
weight: 30
- type: score-comparer@1
score-provider:
type: usage-scorer@1
Expand All @@ -46,18 +23,31 @@ Work Dynamic:
max-items: 5
- until: 168:00:00
weight: 1
max-items: 10
- type: last-opened-comparer@1
max-items: 10
- type: az-comparer@1
property: Name
weight: 1
Work:
type: composition-comparer@1
comparers:
- type: score-comparer@1
score-provider:
score-provider:
type: is-pinned-scorer@1
weight: 1
- type: score-comparer@1
score-provider:
type: tag-scorer@1
weight: 1
tag: Team1
- type: score-comparer@1
score-provider:
type: tag-scorer@1
weight: 1
tag: Work
- type: az-comparer@1
property: Name
weight: 1
Prive:
Work Dynamic:
type: composition-comparer@1
comparers:
- type: score-comparer@1
Expand All @@ -68,7 +58,7 @@ Prive:
score-provider:
type: tag-scorer@1
weight: 1
tag: Prive
tag: Team1
- type: score-comparer@1
score-provider:
type: usage-scorer@1
Expand All @@ -88,6 +78,11 @@ Prive:
max-items: 10
- type: last-opened-comparer@1
weight: 1
- type: score-comparer@1
score-provider:
type: tag-scorer@1
weight: 1
tag: Work
- type: az-comparer@1
property: Name
weight: 1
weight: 1
Loading