diff --git a/src/GitTabExpansion.ps1 b/src/GitTabExpansion.ps1 index 61a1de9a8..8bb662237 100644 --- a/src/GitTabExpansion.ps1 +++ b/src/GitTabExpansion.ps1 @@ -194,7 +194,7 @@ function GitTabExpansionInternal($lastBlock) { # Handles tgit (tortoisegit) if ($lastBlock -match "^$(Get-AliasPattern tgit) (?\S*)$") { # Need return statement to prevent fall-through. - return $tortoiseGitCommands | Where-Object { $_ -like "$($matches['cmd'])*" } + return $Global:TortoiseGitSettings.TortoiseGitCommands.Keys.GetEnumerator() | Sort-Object | Where-Object { $_ -like "$($matches['cmd'])*" } } # Handles gitk @@ -215,9 +215,9 @@ function GitTabExpansionInternal($lastBlock) { gitCmdOperations $gitflowsubcommands $matches['cmd'] $matches['op'] } - # Handles git flow + # Handles git flow "^flow (?\S*)\s+(?\S*)\s+(?\S*)$" { - gitFeatures $matches['name'] $matches['command'] + gitFeatures $matches['name'] $matches['command'] } # Handles git remote (rename|rm|set-head|set-branches|set-url|show|prune) diff --git a/src/TortoiseGit.ps1 b/src/TortoiseGit.ps1 index accf6a2cc..961e9ba35 100644 --- a/src/TortoiseGit.ps1 +++ b/src/TortoiseGit.ps1 @@ -1,70 +1,85 @@ -# TortoiseGit +# TortoiseGit function private:Get-TortoiseGitPath { - if ((Test-Path "C:\Program Files\TortoiseGit\bin\TortoiseGitProc.exe") -eq $true) { - # TortoiseGit 1.8.0 renamed TortoiseProc to TortoiseGitProc. - return "C:\Program Files\TortoiseGit\bin\TortoiseGitProc.exe" - } + if ((Test-Path "C:\Program Files\TortoiseGit\bin\TortoiseGitProc.exe") -eq $true) { + # TortoiseGit 1.8.0 renamed TortoiseProc to TortoiseGitProc. + return "C:\Program Files\TortoiseGit\bin\TortoiseGitProc.exe" + } - return "C:\Program Files\TortoiseGit\bin\TortoiseProc.exe" + return "C:\Program Files\TortoiseGit\bin\TortoiseProc.exe" } $Global:TortoiseGitSettings = new-object PSObject -Property @{ - TortoiseGitPath = (Get-TortoiseGitPath) + TortoiseGitPath = (Get-TortoiseGitPath) + TortoiseGitCommands = @{ + "about" = "about"; + "add" = "add"; + "blame" = "blame"; + "cat" = "cat"; + "cleanup" = "cleanup"; + "clean" = "cleanup"; + "commit" = "commit"; + "conflicteditor" = "conflicteditor"; + "createpatch" = "createpatch"; + "patch" = "createpatch"; + "diff" = "diff"; + "export" = "export"; + "help" = "help"; + "ignore" = "ignore"; + "log" = "log"; + "merge" = "merge"; + "pull" = "pull"; + "push" = "push"; + "rebase" = "rebase"; + "refbrowse" = "refbrowse"; + "reflog" = "reflog"; + "remove" = "remove"; + "rm" = "remove"; + "rename" = "rename"; + "mv" = "rename"; + "repocreate" = "repocreate"; + "init" = "repocreate"; + "repostatus" = "repostatus"; + "status" = "repostatus"; + "resolve" = "resolve"; + "revert" = "revert"; + "settings" = "settings"; + "config" = "settings"; + "stash" = "stash"; + "stashapply" = "stashapply"; + "stashsave" = "stashsave"; + "subadd" = "subadd"; + "subsync" = "subsync"; + "subupdate" = "subupdate"; + "switch" = "switch"; + "checkout" = "switch"; + "fetch" = "sync"; + "sync" = "sync"; + } } function tgit { - if($args) { - if($args[0] -eq "help") { - # Replace the built-in help behaviour with just a list of commands - $tortoiseGitCommands - return - } + if($args) { + # Replace any aliases with actual TortoiseGit commands + if ($Global:TortoiseGitSettings.TortoiseGitCommands.ContainsKey($args[0])) { + $args[0] = $Global:TortoiseGitSettings.TortoiseGitCommands.Get_Item($args[0]) + } + + if($args[0] -eq "help") { + # Replace the built-in help behaviour with just a list of commands + $Global:TortoiseGitSettings.TortoiseGitCommands.Values.GetEnumerator() | Sort-Object | Get-Unique + return + } - $newArgs = @() - $newArgs += "/command:" + $args[0] - - $cmd = $args[0] - - if($args.length -gt 1) { - $args[1..$args.length] | % { $newArgs += $_ } + $newArgs = @() + $newArgs += "/command:" + $args[0] + + $cmd = $args[0] + + if($args.length -gt 1) { + $args[1..$args.length] | ForEach-Object { $newArgs += $_ } + } + + & $Global:TortoiseGitSettings.TortoiseGitPath $newArgs } - - & $Global:TortoiseGitSettings.TortoiseGitPath $newArgs - } } - -$tortoiseGitCommands = @( -"about", -"log", -"commit", -"add", -"revert", -"cleanup" , -"resolve", -"switch", -"export", -"merge", -"settings", -"remove", -"rename", -"diff", -"conflicteditor", -"help", -"ignore", -"blame", -"cat", -"createpatch", -"pull", -"push", -"rebase", -"stashsave", -"stashapply", -"subadd", -"subupdate", -"subsync", -"reflog", -"refbrowse", -"sync", -"repostatus" -) | sort