-
-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds aliasing support for TortoiseGit commands #394
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# TortoiseGit | ||
# TortoiseGit | ||
|
||
function private:Get-TortoiseGitPath { | ||
if ((Test-Path "C:\Program Files\TortoiseGit\bin\TortoiseGitProc.exe") -eq $true) { | ||
|
@@ -11,60 +11,74 @@ function private:Get-TortoiseGitPath { | |
|
||
$Global:TortoiseGitSettings = new-object PSObject -Property @{ | ||
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"; | ||
"sync" = "sync"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to alias There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. |
||
} | ||
} | ||
|
||
function tgit { | ||
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 | ||
$tortoiseGitCommands | ||
return | ||
$Global:TortoiseGitSettings.TortoiseGitCommands.Values.GetEnumerator() | sort | Get-Unique | ||
return | ||
} | ||
|
||
$newArgs = @() | ||
$newArgs += "/command:" + $args[0] | ||
|
||
$cmd = $args[0] | ||
|
||
if($args.length -gt 1) { | ||
$args[1..$args.length] | % { $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 | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EOL @ EOF, please! (Tip: we have a .editorconfig that will enforce this for supported editors.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/sort/Sort-Object/
(also in TortoiseGit.ps1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. PowerShell Core running on Linux or macOS does not have the sort alias defined for Sort-Object. So calling sort would execute the native sort utility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.