Skip to content

Commit

Permalink
Refactor gitConfigKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
rdnlsmith committed Oct 23, 2020
1 parent ce376ff commit 53b0c22
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 30 deletions.
36 changes: 8 additions & 28 deletions src/GitParamTabExpansion.ps1
Expand Up @@ -151,22 +151,12 @@ $gitParamValues = @{
decorate = 'short full no'
'no-walk' = 'sorted unsorted'
pretty = {
param($ref)
$completions = @()
gitConfigKeys $ref 'pretty' | ForEach-Object { $completions += $_ }
'oneline short medium full fuller email raw' -split ' ' |
Where-Object { $_ -like "$filter*" } |
ForEach-Object { $completions += $_ }
return $completions | Sort-Object
param($format)
gitConfigKeys 'pretty' $format 'oneline short medium full fuller email raw'
}
format = {
param($ref)
$completions = @()
gitConfigKeys $ref 'pretty' | ForEach-Object { $completions += $_ }
'oneline short medium full fuller email raw' -split ' ' |
Where-Object { $_ -like "$filter*" } |
ForEach-Object { $completions += $_ }
return $completions | Sort-Object
param($format)
gitConfigKeys 'pretty' $format 'oneline short medium full fuller email raw'
}
encoding = 'UTF-8'
date = 'relative local default iso rfc short raw'
Expand Down Expand Up @@ -206,22 +196,12 @@ $gitParamValues = @{
}
show = @{
pretty = {
param($ref)
$completions = @()
gitConfigKeys $ref 'pretty' | ForEach-Object { $completions += $_ }
'oneline short medium full fuller email raw' -split ' ' |
Where-Object { $_ -like "$filter*" } |
ForEach-Object { $completions += $_ }
return $completions | Sort-Object
param($format)
gitConfigKeys 'pretty' $format 'oneline short medium full fuller email raw'
}
format = {
param($ref)
$completions = @()
gitConfigKeys $ref 'pretty' | ForEach-Object { $completions += $_ }
'oneline short medium full fuller email raw' -split ' ' |
Where-Object { $_ -like "$filter*" } |
ForEach-Object { $completions += $_ }
return $completions | Sort-Object
param($format)
gitConfigKeys 'pretty' $format 'oneline short medium full fuller email raw'
}
encoding = 'utf-8'
}
Expand Down
9 changes: 7 additions & 2 deletions src/GitTabExpansion.ps1
Expand Up @@ -155,10 +155,15 @@ function script:gitRemoteUniqueBranches($filter) {
quoteStringWithSpecialChars
}

function script:gitConfigKeys($filter, $section) {
function script:gitConfigKeys($section, $filter, $defaultOptions = '') {
$completions = @($defaultOptions -split ' ')

git config --name-only --get-regexp ^$section\..* |
ForEach-Object { $_ -replace "$section\.","" } |
ForEach-Object { $completions += ($_ -replace "$section\.","") }

return $completions |
Where-Object { $_ -like "$filter*" } |
Sort-Object |
quoteStringWithSpecialChars
}

Expand Down

0 comments on commit 53b0c22

Please sign in to comment.