Skip to content

Commit 80d0b78

Browse files
committed
feat🚸 (Invoke-GitCheckout): sort the branch options when invoke Invoke-GitCheckout
1 parent 1ed7b37 commit 80d0b78

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

‎PSGitUtils/PSGitUtils.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PSGitUtils.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.12.2'
15+
ModuleVersion = '1.13.0'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

‎PSGitUtils/PSGitUtils.psm1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ function Get-OptionsForChoosingLocalOrOriginBranch {
260260
[string[]]$branches = $localBranches + $originBranches | Select-Object -Unique
261261
[char[]]$existChars = @('q')
262262

263+
$charBranchDict = @() # char:branch key:value
264+
263265
for ($i = 0; $i -lt $branches.Count; $i++) {
264266
$branch = $branches[$i]
265267

@@ -286,11 +288,16 @@ function Get-OptionsForChoosingLocalOrOriginBranch {
286288

287289
if ($branchCharIndex -ne -1) {
288290
$branch = $branch.Insert(($branchCharIndex + $typeLength), '&')
291+
Write-Host $existChars
292+
$charBranchDict += @{k = $existChars[-1]; v = $branch }
293+
} else {
294+
$branchOptions += $branch
289295
}
290-
291-
$branchOptions += $branch
292296
}
293297

298+
# sort the branch options
299+
$branchOptions = ($charBranchDict | Sort-Object -Property k | Select-Object -Property v).v + $branchOptions
300+
294301
$branchOptions += "&quit"
295302

296303
$choice = $host.UI.PromptForChoice($title, $message, $branchOptions, $branchOptions.Count - 1)

0 commit comments

Comments
 (0)