feat: Add GitRepoRegistration cmdlets #5

Merged
pascal_nulah merged 69 commits from feature/git-provider into dev 2026-09-06 09:33:36 +10:00
2 changed files with 12 additions and 1 deletions
Showing only changes of commit 46eeb0cb1e - Show all commits

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
Scott 2026-08-26 14:16:48 +10:00

View file

@ -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
/// <summary>
/// Returns the git root directory for any nested directory if git rev-parse --show-toplevel returns a value.
/// <para>
/// Will always return a non-null value if the directory is a git repo, otherwise an exception will be thrown
/// </para>
/// </summary>
/// <param name="path">Path to check if it or any of its parents contain a git repository</param>
/// <returns></returns>
@ -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
{

View file

@ -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();