From 830ae2c5606856e1bea78be4a2eaf2063f2290eb Mon Sep 17 00:00:00 2001 From: Scott Date: Fri, 7 Aug 2026 08:51:54 +1000 Subject: [PATCH] feat(git-provider): add inital implementation for New-GitRepo --- src/PowershellModule/Git/GitProvider.cs | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/PowershellModule/Git/GitProvider.cs b/src/PowershellModule/Git/GitProvider.cs index 5b290be..46ce4cd 100644 --- a/src/PowershellModule/Git/GitProvider.cs +++ b/src/PowershellModule/Git/GitProvider.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Management.Automation; using System.Management.Automation.Provider; @@ -65,4 +66,35 @@ public class GitProvider : NavigationCmdletProvider { throw new System.NotImplementedException(); } +} + +[Cmdlet(VerbsCommon.New, Noun)] +public class RegisterGitRepo : PSCmdlet +{ + private const string Noun = "GitRepo"; + + [Parameter( + Mandatory = true, + Position = 0, + ValueFromPipeline = true, + HelpMessage = "Reference name for the repo")] + public string Name { get; set; } + + protected override void BeginProcessing() + { + var pwd = this.SessionState.Path.CurrentLocation.Path; + WriteObject("Checking if current directory is a git repository..."); + var ps = new ProcessStartInfo( //$"git -C \"{pwd}\" rev-parse --show-toplevel") + "git", ["rev-parse", "--show-toplevel"]) + { + RedirectStandardOutput = true, + RedirectStandardError = true, + WorkingDirectory = pwd + }; + var a = Process.Start(ps); + Console.WriteLine(a.StandardOutput.ReadToEnd()); + Console.WriteLine(a.StandardError.ReadToEnd()); + + base.BeginProcessing(); + } } \ No newline at end of file