feat: Add GitRepoRegistration cmdlets #5
1 changed files with 8 additions and 12 deletions
chore(git-provider): Use -C when checking if current directory is a git repo
- move WriteDebug to IsGitRepo - inline variable for SessionState.Path.CurrentLocation.Path
commit
7b59b90572
|
|
@ -15,22 +15,15 @@ public sealed class NewGitRepoCommand : PSCmdlet
|
|||
HelpMessage = "Reference name for the repo")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
public NewGitRepoCommand()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void BeginProcessing()
|
||||
{
|
||||
var pwd = this.SessionState.Path.CurrentLocation.Path;
|
||||
WriteDebug("Checking if current directory is a git repository...");
|
||||
|
||||
GitManager.SetDebugWriter(WriteDebug);
|
||||
|
||||
var repoFolfder = IsGitRepo(pwd);
|
||||
var repoFolder = IsGitRepo(SessionState.Path.CurrentLocation.Path);
|
||||
|
||||
if (repoFolfder is not null)
|
||||
if (repoFolder is not null)
|
||||
{
|
||||
GitManager.Instance.RegisterRepo(repoFolfder.Directory, Name ?? repoFolfder.Folder);
|
||||
GitManager.Instance.RegisterRepo(repoFolder.Directory, Name ?? repoFolder.Folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -52,12 +45,13 @@ public sealed class NewGitRepoCommand : PSCmdlet
|
|||
|
||||
private ParsedGitFolderDetails? IsGitRepo(string path)
|
||||
{
|
||||
WriteDebug("Checking if current directory is a git repository...");
|
||||
|
||||
var ps = new ProcessStartInfo("git",
|
||||
["rev-parse", "--show-toplevel"])
|
||||
["-C", path, "rev-parse", "--show-toplevel"])
|
||||
{
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
WorkingDirectory = path
|
||||
};
|
||||
|
||||
// If the user doesn't have git on their path, this will throw an exception that I don't have to do anything
|
||||
|
|
@ -79,6 +73,8 @@ public sealed class NewGitRepoCommand : PSCmdlet
|
|||
// Gotta trim what we get as it might already have a newline character at the end
|
||||
var dirInfo = new DirectoryInfo(directory.Trim());
|
||||
|
||||
WriteDebug("...location is a git repo (duh).");
|
||||
|
||||
var repoFolderInfo = new ParsedGitFolderDetails
|
||||
{
|
||||
Directory = dirInfo.FullName,
|
||||
|
|
|
|||
Loading…
Reference in a new issue