Functions/Get-CurrentRepo.ps1
function Get-CurrentRepo { param( [string] [Parameter(HelpMessage = "The directory within which your repositories will be checked out (e.g. /src/)")] $RootPath = $GitTool.Directory ) $cwd = Get-Location if (-not $cwd.Path.StartsWith($RootPath)) { Write-Error -Category ObjectNotFound -Message "You are not in a valid, managed, repository." -RecommendedAction "Switch directories to a managed repository under your $RootPath directory." return } if (-not (Test-Path -PathType Container -Path ".git")) { Write-Error -Category ObjectNotFound -Message "You are not at the root of a valid, managed, repository." -RecommendedAction "Switch directories to the root directory of a git repository." return } $relativePath = $cwd.Path.Substring($RootPath.Length).Replace([System.IO.Path]::DirectorySeparatorChar, "/").Trim("/") $components = $relativePath -split "/" $Service = $components[0] $Repo = $components[1..$($components.Length)] -join "/" return Get-RepoInfo -Path $RootPath -Repo $Repo -Service $Service } |