From 867d129faa8105984cb5cdf780fee5b2b80aaeee Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Sat, 5 May 2018 14:28:48 -0500 Subject: [PATCH] Update subcommand lists --- src/GitTabExpansion.ps1 | 37 ++++++++++++++++++++++++++----------- test/TabExpansion.Tests.ps1 | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/src/GitTabExpansion.ps1 b/src/GitTabExpansion.ps1 index 10af884f5..d6a9c66cc 100644 --- a/src/GitTabExpansion.ps1 +++ b/src/GitTabExpansion.ps1 @@ -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 = @{ @@ -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', diff --git a/test/TabExpansion.Tests.ps1 b/test/TabExpansion.Tests.ps1 index 990c2a2dc..21179504b 100644 --- a/test/TabExpansion.Tests.ps1 +++ b/test/TabExpansion.Tests.ps1 @@ -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