Functions/Remove-GitRemote.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
function Remove-GitRemote { [CmdletBinding(SupportsShouldProcess)] [OutputType([LibGit2Sharp.Remote])] param ( [string] $RepoRoot, [Parameter(Mandatory, Position = 0, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] [string] $Name ) process { $repo = Find-GitRepository -Verify if (-not $repo) { return } $shouldProcessCaption = "Deleting git remote" $shouldProcessDescription = "Deleting the git remote `"$Name`" in the repository `"$($repo.RepositoryName)`"." $shouldProcessWarning = "Do you want to create the git remote `"$Name`" in the repository `"$($repo.RepositoryName)`"?" if ($PSCmdlet.ShouldProcess($shouldProcessDescription, $shouldProcessWarning, $shouldProcessCaption)) { $repo.Network.Remotes.Remove($Name) } } } |