Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete user-defined pretty formats #802

Merged
merged 3 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions src/GitParamTabExpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,24 @@ $gitParamValues = @{
log = @{
decorate = 'short full no'
'no-walk' = 'sorted unsorted'
pretty = 'oneline short medium full fuller email raw'
format = 'oneline short medium full fuller email raw'
pretty = {
param($ref)
dahlbyk marked this conversation as resolved.
Show resolved Hide resolved
$completions = @()
gitConfigKeys $ref 'pretty' | ForEach-Object { $completions += $_ }
'oneline short medium full fuller email raw' -split ' ' |
dahlbyk marked this conversation as resolved.
Show resolved Hide resolved
Where-Object { $_ -like "$filter*" } |
ForEach-Object { $completions += $_ }
return $completions | Sort-Object
}
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
}
encoding = 'UTF-8'
date = 'relative local default iso rfc short raw'
}
Expand Down Expand Up @@ -189,8 +205,24 @@ $gitParamValues = @{
strategy = 'resolve recursive octopus ours subtree'
}
show = @{
pretty = 'oneline short medium full fuller email raw'
format = 'oneline short medium full fuller email raw'
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
}
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
}
encoding = 'utf-8'
}
status = @{
Expand Down
7 changes: 7 additions & 0 deletions src/GitTabExpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ function script:gitRemoteUniqueBranches($filter) {
quoteStringWithSpecialChars
}

function script:gitConfigKeys($filter, $section) {
git config --name-only --get-regexp ^$section\..* |
ForEach-Object { $_ -replace "$section\.","" } |
Where-Object { $_ -like "$filter*" } |
quoteStringWithSpecialChars
}

function script:gitTags($filter, $prefix = '') {
git tag |
Where-Object { $_ -like "$filter*" } |
Expand Down