Skip to content

Commit

Permalink
Tab completion for sparse-checkout parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
bgold09 committed Jul 24, 2022
1 parent f9aba15 commit ec20d89
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/GitParamTabExpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $shortGitParams = @{
revert = 'e m n S s X'
rm = 'f n r q'
shortlog = 'n s e w'
'sparse-checkout' = ''
stash = 'p k u a q'
status = 's b u z'
submodule = 'q b f n N'
Expand Down Expand Up @@ -77,6 +78,7 @@ $longGitParams = @{
rm = 'force dry-run cached ignore-unmatch quiet'
shortlog = 'numbered summary email format='
show = 'pretty= format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes show-notes no-standard-notes standard-notes show-signature'
'sparse-checkout' = ''
stash = 'patch no-keep-index keep-index include-untracked all quiet index'
status = 'short branch porcelain long untracked-files ignore-submodules ignored column no-column'
submodule = 'quiet branch force cached files summary-limit remote no-fetch checkout merge rebase init name reference recursive depth'
Expand Down Expand Up @@ -109,6 +111,12 @@ $longVstsParams = @{
update = " $longVstsGlobal"
}

$longSparseCheckoutParams = @{
add = "stdin"
set = "cone no-cone sparse-index no-sparse-index stdin"
reapply = "cone no-cone sparse-index no-sparse-index"
}

# Variable is used in GitTabExpansion.ps1
$gitParamValues = @{
blame = @{
Expand Down
1 change: 1 addition & 0 deletions src/GitTabExpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ $script:gitCommandsWithShortParams = $shortGitParams.Keys -join '|'
$script:gitCommandsWithParamValues = $gitParamValues.Keys -join '|'
$script:vstsCommandsWithShortParams = $shortVstsParams.Keys -join '|'
$script:vstsCommandsWithLongParams = $longVstsParams.Keys -join '|'
$script:sparseCheckoutCommandsWithLongParams = $longSparseCheckoutParams.Keys -join '|'

# The regular expression here is roughly follows this pattern:
#
Expand Down
22 changes: 22 additions & 0 deletions test/GitParamTabExpansion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,27 @@ Describe 'ParamsTabExpansion Tests' {
$result -contains '--format=test2' | Should -Be $true
}
}

Context 'Sparse-Checkout Parameters TabExpansion Tests' {
It 'Tab completes all long sparse-checkout set parameters' {
$result = & $module GitTabExpansionInternal 'git sparse-checkout set --'
$result -contains '--cone' | Should -Be $true
$result -contains '--no-cone' | Should -Be $true
$result -contains '--sparse-index' | Should -Be $true
$result -contains '--no-sparse-index' | Should -Be $true
$result -contains '--stdin' | Should -Be $true
}
It 'Tab completes all long sparse-checkout reapply parameters' {
$result = & $module GitTabExpansionInternal 'git sparse-index reapply --'
$result -contains '--cone' | Should -Be $true
$result -contains '--no-cone' | Should -Be $true
$result -contains '--sparse-index' | Should -Be $true
$result -contains '--no-sparse-index' | Should -Be $true
}
It 'Tab completes all long sparse-checkout add parameters' {
$result = & $module GitTabExpansionInternal 'git sparse-checkout add --'
$result -contains '--stdin' | Should -Be $true
}
}
}

0 comments on commit ec20d89

Please sign in to comment.