Skip to content

Commit

Permalink
Add branch name completion to Name param of Remove-GitBranch
Browse files Browse the repository at this point in the history
  • Loading branch information
rkeithhill committed Apr 28, 2019
1 parent b6351ba commit 491d621
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/GitTabExpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ function GitTabExpansionInternal($lastBlock, $GitStatus = $null) {
return gitBranches $matches['ref'] $true
}

# Handles Remove-GitBranch
if (($lastBlock -match "^Remove-GitBranch\s+(?!-)(?<ref>\S*)") -or
($lastBlock -match "^Remove-GitBranch.* -Name\s+(?<ref>\S*)")) {
return gitBranches $matches['ref'] $true
}

switch -regex ($lastBlock -replace "^$(Get-AliasPattern git) ","") {

# Handles git <cmd> <op>
Expand Down Expand Up @@ -440,7 +446,6 @@ function GitTabExpansionInternal($lastBlock, $GitStatus = $null) {
{
expandShortParams $shortVstsParams $matches['cmd'] $matches['shortparam']
}

}
}

Expand Down Expand Up @@ -469,6 +474,7 @@ function TabExpansion($line, $lastWord) {
"^$(Get-AliasPattern git) (.*)" { Expand-GitCommand $lastBlock }
"^$(Get-AliasPattern tgit) (.*)" { Expand-GitCommand $lastBlock }
"^$(Get-AliasPattern gitk) (.*)" { Expand-GitCommand $lastBlock }
"^$(Get-AliasPattern Remove-GitBranch) (.*)" { Expand-GitCommand $lastBlock }

# Fall back on existing tab expansion
default {
Expand Down
4 changes: 2 additions & 2 deletions src/GitUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ function InDotGitOrBareRepoDir([string][ValidateNotNullOrEmpty()]$GitDir) {
$res
}

function Get-AliasPattern($exe) {
$aliases = @($exe) + @(Get-Alias | Where-Object { $_.Definition -eq $exe } | Select-Object -Exp Name)
function Get-AliasPattern($cmd) {
$aliases = @($cmd) + @(Get-Alias | Where-Object { $_.Definition -eq $cmd } | Select-Object -Exp Name)
"($($aliases -join '|'))"
}

Expand Down

0 comments on commit 491d621

Please sign in to comment.