From 1363f6ce02353d73061a05cd55f0e615656d5b5f Mon Sep 17 00:00:00 2001 From: Scott Date: Fri, 7 Aug 2026 16:49:30 +1000 Subject: [PATCH] chore(git-provider): explore setting the location based on a child fragment match --- src/PowershellModule/Git/GitProvider.cs | 18 ++++++++++++++++++ src/PowershellModule/Git/NewGitRepoCommand.cs | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/PowershellModule/Git/GitProvider.cs b/src/PowershellModule/Git/GitProvider.cs index 5b290be..e340c2b 100644 --- a/src/PowershellModule/Git/GitProvider.cs +++ b/src/PowershellModule/Git/GitProvider.cs @@ -61,6 +61,24 @@ public class GitProvider : NavigationCmdletProvider return true; } + protected override string MakePath(string parent, string child) + { + // Test to see what happens if set the location if the path matches a pretend repo registered with the name test + // The result of the test is that yes, this does work, but there's also a shit load of calls to this method as + // it traverses the entire directory path. + // This seems to just be internal powershell behaviour so as long as this is quick the first time, everything + // afterwards just always happens. But probably happens more seeing as I'm changing the location of the path + // in this current SessionState and probably doesn't happen if this were a normal path traversal + // where I don't set the location. + if (child == "test") + { + SessionState.Path.SetLocation("F:/Repos/PowershellModule/src/PowershellModule/Git"); + return "F:/Repos/PowershellModule/src/PowershellModule/Git"; + } + + return base.MakePath(parent, child); + } + protected override bool IsValidPath(string path) { throw new System.NotImplementedException(); diff --git a/src/PowershellModule/Git/NewGitRepoCommand.cs b/src/PowershellModule/Git/NewGitRepoCommand.cs index 583a616..3486a91 100644 --- a/src/PowershellModule/Git/NewGitRepoCommand.cs +++ b/src/PowershellModule/Git/NewGitRepoCommand.cs @@ -33,7 +33,6 @@ public class NewGitRepoCommand : PSCmdlet var repoFolfder = IsGitRepo(pwd); - base.BeginProcessing(); } @@ -114,6 +113,7 @@ public class SetGitRepoCommand : PSCmdlet protected override void BeginProcessing() { + SessionState.Path.SetLocation("F:/Repos/PowershellModule/src/PowershellModule/Git"); base.BeginProcessing(); } }