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
Showing only changes of commit b91a868a54 - Show all commits

feat(git-provider): Update Remove-GitRepoRegistration to work from any directory when -Name is given

Scott 2026-09-02 11:18:26 +10:00

View file

@ -19,11 +19,18 @@ public class RemoveGitRepoRegistrationCommand : PSCmdlet
{
GitManager.SetDebugWriter(WriteDebug);
var repoFolder = GitManager.IsGitRepo(SessionState.Path.CurrentLocation.Path);
// If we aren't given a value for the Name argument, default behaviour is to attempt to remove a registration
// by the current git repo folder name for the current location.
// If we have a name, don't bother testing for a git repo, just attempt to remove the registration by name
// regardless of where we're being called from
var registrationNameToRemove = string.IsNullOrEmpty(Name)
? GitManager.IsGitRepo(SessionState.Path.CurrentLocation.Path).Folder
: Name;
GitManager.Instance.UnregisterRepo(registrationNameToRemove);
// Removing a registration works similar to registering a new one - we either remove by exact name, or by
// the folder if no name is given (so a user can remove a registration from a git repo they're currently in)
GitManager.Instance.UnregisterRepo(Name ?? repoFolder.Folder);
GitManager.ClearDebugWriter();
base.BeginProcessing();