diff --git a/src/ModuleCore/Git/GitManager.cs b/src/ModuleCore/Git/GitManager.cs index 264ff5a..895bbb4 100644 --- a/src/ModuleCore/Git/GitManager.cs +++ b/src/ModuleCore/Git/GitManager.cs @@ -8,13 +8,6 @@ namespace ModuleCore.Git; public class GitManager { private static readonly Lazy GitManagerInstance = new(() => new GitManager()); - public static GitManager Instance => GitManagerInstance.Value; - - /// - /// Always returns a new clean instance of GitManager - /// - internal static GitManager InternalFreshInstance => new(); - private readonly ConcurrentDictionary _registrations; private GitManager() @@ -24,8 +17,15 @@ public class GitManager _registrations = new ConcurrentDictionary(); } + public static GitManager Instance => GitManagerInstance.Value; + /// - /// Registers a git repository based on an absolute location. If is null or empty, + /// Always returns a new clean instance of GitManager + /// + internal static GitManager InternalFreshInstance => new(); + + /// + /// Registers a git repository based on an absolute location. If is null or empty, /// the registration will use the folder name for the git repo at the top level. /// /// @@ -37,7 +37,7 @@ public class GitManager ? new DirectoryInfo(absoluteRepositoryLocation).Name : registrationName; - if (_registrations.TryAdd(registrationName, new InternalGitRegistration() + if (_registrations.TryAdd(registrationName, new InternalGitRegistration { Name = registrationName, Location = absoluteRepositoryLocation, @@ -51,7 +51,15 @@ public class GitManager public List 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) @@ -74,13 +82,12 @@ public class GitManager /// private class InternalGitRegistration { + private string _currentBranch = string.Empty; + private long _nextCheckTime; public required string Name { get; set; } public required string Location { get; set; } 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 private string GetCurrentBranch() {