diff --git a/GitTabExpansion.ps1 b/GitTabExpansion.ps1 index a4ec366d2..0edc966fa 100644 --- a/GitTabExpansion.ps1 +++ b/GitTabExpansion.ps1 @@ -69,10 +69,9 @@ function script:gitRemotes($filter) { Where-Object { $_ -like "$filter*" } } -function script:gitBranches($filter, $includeHEAD = $false) { - $prefix = $null +function script:gitBranches($filter, $includeHEAD = $false, $prefix = '') { if ($filter -match "^(?\S*\.{2,3})(?.*)") { - $prefix = $matches['from'] + $prefix += $matches['from'] $filter = $matches['to'] } $branches = @(git branch --no-color | ForEach-Object { if($_ -match "^\*?\s*(?.*)") { $matches['ref'] } }) + @@ -83,9 +82,10 @@ function script:gitBranches($filter, $includeHEAD = $false) { ForEach-Object { $prefix + $_ } } -function script:gitTags($filter) { +function script:gitTags($filter, $prefix = '') { git tag | - Where-Object { $_ -like "$filter*" } + Where-Object { $_ -like "$filter*" } | + ForEach-Object { $prefix + $_ } } function script:gitFeatures($filter, $command){ @@ -96,10 +96,10 @@ function script:gitFeatures($filter, $command){ ForEach-Object { $prefix + $_ } } -function script:gitRemoteBranches($remote, $ref, $filter) { +function script:gitRemoteBranches($remote, $ref, $filter, $prefix = '') { git branch --no-color -r | Where-Object { $_ -like " $remote/$filter*" } | - ForEach-Object { $ref + ($_ -replace " $remote/","") } + ForEach-Object { $prefix + $ref + ($_ -replace " $remote/","") } } function script:gitStashes($filter) { @@ -241,15 +241,17 @@ function GitTabExpansion($lastBlock) { } # Handles git push remote : - "^push.* (?\S+) (?[^\s\:]*\:)(?\S*)$" { - gitRemoteBranches $matches['remote'] $matches['ref'] $matches['branch'] + # Handles git push remote +: + "^push.* (?\S+) (?\+?)(?[^\s\:]*\:)(?\S*)$" { + gitRemoteBranches $matches['remote'] $matches['ref'] $matches['branch'] -prefix $matches['force'] } # Handles git push remote + # Handles git push remote + # Handles git pull remote - "^(?:push|pull).* (?:\S+) (?[^\s\:]*)$" { - gitBranches $matches['ref'] - gitTags $matches['ref'] + "^(?:push|pull).* (?:\S+) (?\+?)(?[^\s\:]*)$" { + gitBranches $matches['ref'] -prefix $matches['force'] + gitTags $matches['ref'] -prefix $matches['force'] } # Handles git pull