Skip to content

Commit

Permalink
feat🚸 (Invoke-GitCheckout): sort the branch options when invoke Invok…
Browse files Browse the repository at this point in the history
…e-GitCheckout
  • Loading branch information
capdiem committed Jul 18, 2022
1 parent 1ed7b37 commit 80d0b78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PSGitUtils/PSGitUtils.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PSGitUtils.psm1'

# Version number of this module.
ModuleVersion = '1.12.2'
ModuleVersion = '1.13.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
11 changes: 9 additions & 2 deletions PSGitUtils/PSGitUtils.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ function Get-OptionsForChoosingLocalOrOriginBranch {
[string[]]$branches = $localBranches + $originBranches | Select-Object -Unique
[char[]]$existChars = @('q')

$charBranchDict = @() # char:branch key:value

for ($i = 0; $i -lt $branches.Count; $i++) {
$branch = $branches[$i]

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

if ($branchCharIndex -ne -1) {
$branch = $branch.Insert(($branchCharIndex + $typeLength), '&')
Write-Host $existChars
$charBranchDict += @{k = $existChars[-1]; v = $branch }
} else {
$branchOptions += $branch
}

$branchOptions += $branch
}

# sort the branch options
$branchOptions = ($charBranchDict | Sort-Object -Property k | Select-Object -Property v).v + $branchOptions

$branchOptions += "&quit"

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

0 comments on commit 80d0b78

Please sign in to comment.