functions/_CloneGitRepo.ps1

function _CloneGitRepo
{
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$True)]
        [string] $RepoUrl
    )

    $tempDir = New-TemporaryDirectory
    Push-Location $tempDir.FullName

    Write-Information "Created temporary directory: $($tempDir.FullName)"

    Write-Information "Cloning: $RepoUrl"
    git clone $RepoUrl .
    if ($LASTEXITCODE -ne 0) { throw "git cli returned non-zero exit code cloning the repo - check previous log messages" }

    return $tempDir
}