From 46eeb0cb1ee68387c2a4df6b82c5577b7f1218e7 Mon Sep 17 00:00:00 2001 From: Scott Date: Wed, 26 Aug 2026 14:16:48 +1000 Subject: [PATCH] feat(git-provider): Update debug output when registering - output when no name is given - update message when current location is confirmed to be a git repo --- src/ModuleCore/Git/GitManager.cs | 6 +++++- .../Git/Commands/NewGitRepoRegistrationCommand.cs | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ModuleCore/Git/GitManager.cs b/src/ModuleCore/Git/GitManager.cs index eeb3b60..f301244 100644 --- a/src/ModuleCore/Git/GitManager.cs +++ b/src/ModuleCore/Git/GitManager.cs @@ -108,6 +108,7 @@ public class GitManager if (_registrations.TryAdd(registrationName, gitRegistration)) { + _debugWriterDelegate?.Invoke($"Registered '{gitRegistration.Location}' to name '{registrationName}'"); return registrationName; } @@ -196,6 +197,9 @@ public class GitManager /// /// Returns the git root directory for any nested directory if git rev-parse --show-toplevel returns a value. + /// + /// Will always return a non-null value if the directory is a git repo, otherwise an exception will be thrown + /// /// /// Path to check if it or any of its parents contain a git repository /// @@ -236,7 +240,7 @@ public class GitManager // Gotta trim what we get as it might already have a newline character at the end var dirInfo = new DirectoryInfo(directory.Trim()); - _debugWriterDelegate?.Invoke("...location is a git repo (duh)."); + _debugWriterDelegate?.Invoke("...location is a git repo!"); var repoFolderInfo = new ParsedGitFolderDetails { diff --git a/src/PowershellModule/Git/Commands/NewGitRepoRegistrationCommand.cs b/src/PowershellModule/Git/Commands/NewGitRepoRegistrationCommand.cs index 1f968aa..ec460eb 100644 --- a/src/PowershellModule/Git/Commands/NewGitRepoRegistrationCommand.cs +++ b/src/PowershellModule/Git/Commands/NewGitRepoRegistrationCommand.cs @@ -19,8 +19,15 @@ public sealed class NewGitRepoRegistrationCommand : PSCmdlet { GitManager.SetDebugWriter(WriteDebug); + // Test that we're in a git repo first. If we aren't (or git isn't available), this method will throw + // so we don't need to handle for null (yet). var repoFolder = GitManager.IsGitRepo(SessionState.Path.CurrentLocation.Path); + if (string.IsNullOrWhiteSpace(Name)) + { + WriteDebug("No name given for registration, defaulting to git folder root."); + } + GitManager.Instance.RegisterRepo(repoFolder.Directory, Name ?? repoFolder.Folder); GitManager.ClearDebugWriter();