Skip to content

Commit

Permalink
Update subcommand lists
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed May 5, 2018
1 parent dcb96a4 commit 867d129
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 11 deletions.
37 changes: 26 additions & 11 deletions src/GitTabExpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,31 @@ $Global:GitTabSettings = New-Object PSObject -Property @{
}

$subcommands = @{
bisect = 'start bad good skip reset visualize replay log run'
notes = 'edit show'
reflog = 'expire delete show'
remote = 'add rename rm set-head show prune update'
stash = 'list show drop pop apply branch save clear create'
submodule = 'add status init update summary foreach sync'
svn = 'init fetch clone rebase dcommit branch tag log blame find-rev set-tree create-ignore show-ignore mkdirs commit-diff info proplist propget show-externals gc reset'
tfs = 'bootstrap checkin checkintool ct cleanup cleanup-workspaces clone diagnostics fetch help init pull quick-clone rcheckin shelve shelve-list unshelve verify'
flow = 'init feature bugfix release hotfix support help version config finish delete publish rebase'
worktree = 'add list prune'
bisect = "start bad good skip reset visualize replay log run"
notes = 'add append copy edit get-ref list merge prune remove show'
reflog = "show delete expire"
remote = "
add rename remove set-head set-branches
get-url set-url show prune update
"
rerere = "clear forget diff remaining status gc"
stash = 'push save list show apply clear drop pop create branch'
submodule = "add status init deinit update summary foreach sync"
svn = "
init fetch clone rebase dcommit log find-rev
set-tree commit-diff info create-ignore propget
proplist show-ignore show-externals branch tag blame
migrate mkdirs reset gc
"
tfs = "
list-remote-branches clone quick-clone bootstrap init
clone fetch pull quick-clone unshelve shelve-list labels
rcheckin checkin checkintool shelve shelve-delete
branch
info cleanup cleanup-workspaces help verify autotag subtree reset-remote checkout
"
flow = "init feature release hotfix support help version"
worktree = "add list lock move prune remove unlock"
}

$gitflowsubcommands = @{
Expand All @@ -29,7 +44,7 @@ $gitflowsubcommands = @{
}

function script:gitCmdOperations($commands, $command, $filter) {
$commands.$command -split ' ' | Where-Object { $_ -like "$filter*" }
$commands.$command.Trim() -split '\s+' | Where-Object { $_ -like "$filter*" }
}

$script:someCommands = @('add','am','annotate','archive','bisect','blame','branch','bundle','checkout','cherry',
Expand Down
34 changes: 34 additions & 0 deletions test/TabExpansion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,40 @@ Describe 'TabExpansion Tests' {
It 'Exports a TabExpansion function' {
$module.ExportedFunctions.Keys -contains 'TabExpansion' | Should Be $true
}
Context 'Subcommand TabExpansion Tests' {
It 'Tab completes without subcommands' {
$result = & $module GitTabExpansionInternal 'git whatever '

$result | Should Be @()
}
It 'Tab completes bisect subcommands' {
$result = & $module GitTabExpansionInternal 'git bisect '

$result -contains '' | Should Be $false
$result -contains 'start' | Should Be $true
$result -contains 'run' | Should Be $true

$result2 = & $module GitTabExpansionInternal 'git bisect s'

$result2 -contains 'start' | Should Be $true
$result2 -contains 'skip' | Should Be $true
}
It 'Tab completes remote subcommands' {
$result = & $module GitTabExpansionInternal 'git remote '

$result -contains '' | Should Be $false
$result -contains 'add' | Should Be $true
$result -contains 'set-branches' | Should Be $true
$result -contains 'get-url' | Should Be $true
$result -contains 'update' | Should Be $true

$result2 = & $module GitTabExpansionInternal 'git remote s'

$result2 -contains 'set-branches' | Should Be $true
$result2 -contains 'set-head' | Should Be $true
$result2 -contains 'set-url' | Should Be $true
}
}
Context 'Fetch/Push/Pull TabExpansion Tests' {
BeforeEach {
# Ensure master branch exists
Expand Down

0 comments on commit 867d129

Please sign in to comment.