public/git/Remove-PSTSGitRepositoryRef.ps1

function Remove-PSTSGitRepositoryRef
{
    param(
        [Parameter(Mandatory=$true)][string] $project,
        [Parameter(Mandatory=$true)][string] $repoName,
        [Parameter(Mandatory=$true)][string] $branch
    )



    process {
        $id = $(Get-PSTSGitRepository -project $project | Where-Object {$_.name -eq $repoName} | Select-Object -ExpandProperty id )
        if ([String]::IsNullOrEmpty($id))
        {
            Write-Error "$repoName doesn't exist in $project !!"
            return 128
        }
        else
        {
            Write-Debug "$repoName exists in $project"
            $oldObjectId = Get-PSTSGitRepositoryRef -project $project -id "$id" | Where-Object {$_.name -eq "refs/heads/$branch" }| Select-Object -ExpandProperty objectId
            $payload= New-Object -TypeName "PSObject"
            $payload | Add-Member -MemberType NoteProperty "name" -Value "refs/heads/$branch"
            $payload | Add-Member -MemberType NoteProperty "oldObjectId" -Value   "$oldObjectId"
            $payload | Add-Member -MemberType NoteProperty "newObjectId" -Value   "0000000000000000000000000000000000000000"


            $body = @($payload)
            $content = `
            _PSTSAPI `
                -resource "git/repositories/$id/refs" `
                -method "POST" `
                -project $project `
                -repositoryId $id `
                -body $("[$($body | convertTo-Json)]" )  `
                -contentType "application/json" `
                -apiVersion "api-version=5.1-preview"

            return [GitRefUpdateResult[]]$content.value
       }



    }
}