1- <#
1+ <#
22. SYNOPSIS
33 git branch extension
44. DESCRIPTION
@@ -20,7 +20,7 @@ begin {
2020 <#
2121 If any of these parameters are used, we will skip processing.
2222 #>
23- $SkipIf = ' m' , ' c' , ' column' , ' format' , ' show-current' -join ' |'
23+ $SkipIf = ' m' , ' c' , ' column' , ' format' , ' show-current' -join ' |'
2424 if ($gitCommand -match " \s-(?>$SkipIf )" ) { continue }
2525 $allBranches = @ ()
2626}
@@ -44,7 +44,7 @@ process {
4444
4545 # Current branches will start with an asterisk. Convert this to a boolean.
4646 $IsCurrentBranch = (" $gitOut " -match ' ^\*\s' -as [bool ])
47-
47+
4848 # If the -verbose flag was passed, we have more information in a more predictable fashion.
4949 if ($gitCommand -match ' \s-(?:v|-verbose)' ){
5050 # The branch name and hash are each separated by spaces. Everything else is a commit message.
@@ -57,12 +57,12 @@ process {
5757 CommitMessage = $lastCommitMessage -join ' '
5858 IsCurrentBranch = $IsCurrentBranch
5959 GitRoot = $GitRoot
60- }
60+ }
6161 } else {
6262 # If verbose wasn't passed, the branchname is any whitepsace.
6363 # If remotes were passed, then they may start with origin. We can replace this.
6464 $branchName = " $gitOut " -replace ' ^[\s\*]+' -replace ' ^origin/'
65-
65+
6666 # Add the output to the list of all branches
6767 $allBranches += [PSCustomObject ][Ordered ]@ {
6868 PSTypeName = ' git.branch'
@@ -71,19 +71,19 @@ process {
7171 GitRoot = $GitRoot
7272 }
7373 }
74- # If the user passed their own --sort parameter,
74+ # If the user passed their own --sort parameter,
7575 if ($gitCommand -match ' \s--sort' ) {
7676 $allBranches [-1 ] # don't sort for them and output the branch,
7777 $allBranches = @ () # and reset the list of all branches.
78- }
78+ }
7979}
8080
8181end {
82- # If no --sort was passed,
83- $allBranches |
82+ # If no --sort was passed,
83+ $allBranches |
8484 Sort-Object @ { # then put the current branch first
8585 Expression = ' IsCurrentBranch'
8686 Descending = $true
87- },
87+ },
8888 BranchName # and sort the rest alphabetically.
8989}
0 commit comments