mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-11-19 05:09:53 +01:00
31 lines
758 B
PowerShell
31 lines
758 B
PowerShell
<#
|
|
.Synopsis
|
|
Finds the root of the git repository
|
|
|
|
.Outputs
|
|
A System.IO.DirectoryInfo for the location of the root.
|
|
|
|
.Inputs
|
|
None
|
|
|
|
.Notes
|
|
FileNotFoundException is thrown if the current directory does not contain a CMakeLists.txt file.
|
|
#>
|
|
function Get-RepositoryRoot
|
|
{
|
|
$currentDir = (Get-Item -Path $PSCommandPath).Directory
|
|
|
|
while ($null -ne $currentDir.Parent)
|
|
{
|
|
$path = Join-Path -Path $currentDir.FullName -ChildPath '.git'
|
|
if (Test-Path -Path $path)
|
|
{
|
|
return $currentDir
|
|
}
|
|
$currentDir = $currentDir.Parent
|
|
}
|
|
|
|
throw new-object System.IO.DirectoryNotFoundException("Could not find the root of the GIT repository")
|
|
}
|
|
|
|
Export-ModuleMember -Function Get-RepositoryRoot |