Skip to content

Commit fc2dd32

Browse files
committed
Tab completion for sparse-checkout parameters
1 parent a1002f3 commit fc2dd32

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

src/GitParamTabExpansion.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ $shortGitParams = @{
3232
revert = 'e m n S s X'
3333
rm = 'f n r q'
3434
shortlog = 'n s e w'
35+
'sparse-checkout' = ''
3536
stash = 'p k u a q'
3637
status = 's b u z'
3738
submodule = 'q b f n N'
@@ -77,6 +78,7 @@ $longGitParams = @{
7778
rm = 'force dry-run cached ignore-unmatch quiet'
7879
shortlog = 'numbered summary email format='
7980
show = 'pretty= format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes show-notes no-standard-notes standard-notes show-signature'
81+
'sparse-checkout' = ''
8082
stash = 'patch no-keep-index keep-index include-untracked all quiet index'
8183
status = 'short branch porcelain long untracked-files ignore-submodules ignored column no-column'
8284
submodule = 'quiet branch force cached files summary-limit remote no-fetch checkout merge rebase init name reference recursive depth'
@@ -109,6 +111,12 @@ $longVstsParams = @{
109111
update = " $longVstsGlobal"
110112
}
111113

114+
$longSparseCheckoutParams = @{
115+
add = "stdin"
116+
set = "cone no-cone sparse-index no-sparse-index stdin"
117+
reapply = "cone no-cone sparse-index no-sparse-index"
118+
}
119+
112120
# Variable is used in GitTabExpansion.ps1
113121
$gitParamValues = @{
114122
blame = @{

src/GitTabExpansion.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ $script:gitCommandsWithShortParams = $shortGitParams.Keys -join '|'
7171
$script:gitCommandsWithParamValues = $gitParamValues.Keys -join '|'
7272
$script:vstsCommandsWithShortParams = $shortVstsParams.Keys -join '|'
7373
$script:vstsCommandsWithLongParams = $longVstsParams.Keys -join '|'
74+
$script:sparseCheckoutCommandsWithLongParams = $longSparseCheckoutParams.Keys -join '|'
7475

7576
# The regular expression here is roughly follows this pattern:
7677
#

test/GitParamTabExpansion.Tests.ps1

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,27 @@ Describe 'ParamsTabExpansion Tests' {
150150
$result -contains '--format=test2' | Should -Be $true
151151
}
152152
}
153+
154+
Context 'Sparse-Checkout Parameters TabExpansion Tests' {
155+
It 'Tab completes all long sparse-checkout set parameters' {
156+
$result = & $module GitTabExpansionInternal 'git sparse-checkout set --'
157+
$result -contains '--cone' | Should -Be $true
158+
$result -contains '--no-cone' | Should -Be $true
159+
$result -contains '--sparse-index' | Should -Be $true
160+
$result -contains '--no-sparse-index' | Should -Be $true
161+
$result -contains '--stdin' | Should -Be $true
162+
}
163+
It 'Tab completes all long sparse-checkout reapply parameters' {
164+
$result = & $module GitTabExpansionInternal 'git sparse-index reapply --'
165+
$result -contains '--cone' | Should -Be $true
166+
$result -contains '--no-cone' | Should -Be $true
167+
$result -contains '--sparse-index' | Should -Be $true
168+
$result -contains '--no-sparse-index' | Should -Be $true
169+
}
170+
It 'Tab completes all long sparse-checkout add parameters' {
171+
$result = & $module GitTabExpansionInternal 'git sparse-checkout add --'
172+
$result -contains '--stdin' | Should -Be $true
173+
}
174+
}
153175
}
154176

0 commit comments

Comments
 (0)