chore(git-provider): Code style
This commit is contained in:
parent
54d5dd25b9
commit
93717b4e43
1 changed files with 20 additions and 13 deletions
|
|
@ -8,13 +8,6 @@ namespace ModuleCore.Git;
|
||||||
public class GitManager
|
public class GitManager
|
||||||
{
|
{
|
||||||
private static readonly Lazy<GitManager> GitManagerInstance = new(() => new GitManager());
|
private static readonly Lazy<GitManager> GitManagerInstance = new(() => new GitManager());
|
||||||
public static GitManager Instance => GitManagerInstance.Value;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Always returns a new clean instance of GitManager
|
|
||||||
/// </summary>
|
|
||||||
internal static GitManager InternalFreshInstance => new();
|
|
||||||
|
|
||||||
private readonly ConcurrentDictionary<string, InternalGitRegistration> _registrations;
|
private readonly ConcurrentDictionary<string, InternalGitRegistration> _registrations;
|
||||||
|
|
||||||
private GitManager()
|
private GitManager()
|
||||||
|
|
@ -24,8 +17,15 @@ public class GitManager
|
||||||
_registrations = new ConcurrentDictionary<string, InternalGitRegistration>();
|
_registrations = new ConcurrentDictionary<string, InternalGitRegistration>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static GitManager Instance => GitManagerInstance.Value;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers a git repository based on an absolute location. If <paramref name="registrationName"/> is null or empty,
|
/// Always returns a new clean instance of GitManager
|
||||||
|
/// </summary>
|
||||||
|
internal static GitManager InternalFreshInstance => new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers a git repository based on an absolute location. If <paramref name="registrationName" /> is null or empty,
|
||||||
/// the registration will use the folder name for the git repo at the top level.
|
/// the registration will use the folder name for the git repo at the top level.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="absoluteRepositoryLocation"></param>
|
/// <param name="absoluteRepositoryLocation"></param>
|
||||||
|
|
@ -37,7 +37,7 @@ public class GitManager
|
||||||
? new DirectoryInfo(absoluteRepositoryLocation).Name
|
? new DirectoryInfo(absoluteRepositoryLocation).Name
|
||||||
: registrationName;
|
: registrationName;
|
||||||
|
|
||||||
if (_registrations.TryAdd(registrationName, new InternalGitRegistration()
|
if (_registrations.TryAdd(registrationName, new InternalGitRegistration
|
||||||
{
|
{
|
||||||
Name = registrationName,
|
Name = registrationName,
|
||||||
Location = absoluteRepositoryLocation,
|
Location = absoluteRepositoryLocation,
|
||||||
|
|
@ -51,7 +51,15 @@ public class GitManager
|
||||||
|
|
||||||
public List<GitRegistration> ListRepos()
|
public List<GitRegistration> ListRepos()
|
||||||
{
|
{
|
||||||
return _registrations.Select(x => new GitRegistration() { Name = x.Value.Name, Location = x.Value.Location, CurrentBranch = x.Value.CurrentBranch }).ToList();
|
return _registrations.Select(x =>
|
||||||
|
new GitRegistration
|
||||||
|
{
|
||||||
|
Name = x.Value.Name,
|
||||||
|
Location = x.Value.Location,
|
||||||
|
CurrentBranch = x.Value.CurrentBranch,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRepo(string? registeredName)
|
public string GetRepo(string? registeredName)
|
||||||
|
|
@ -74,13 +82,12 @@ public class GitManager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private class InternalGitRegistration
|
private class InternalGitRegistration
|
||||||
{
|
{
|
||||||
|
private string _currentBranch = string.Empty;
|
||||||
|
private long _nextCheckTime;
|
||||||
public required string Name { get; set; }
|
public required string Name { get; set; }
|
||||||
public required string Location { get; set; }
|
public required string Location { get; set; }
|
||||||
public string CurrentBranch => GetCurrentBranch();
|
public string CurrentBranch => GetCurrentBranch();
|
||||||
|
|
||||||
private string _currentBranch = string.Empty;
|
|
||||||
private long _nextCheckTime;
|
|
||||||
|
|
||||||
// TODO: not fully decided on if I want this feature or not, but keeping it in for now
|
// TODO: not fully decided on if I want this feature or not, but keeping it in for now
|
||||||
private string GetCurrentBranch()
|
private string GetCurrentBranch()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue