@@ -11,19 +11,19 @@ function Parse-GitIndexes($argIndexes, $lookIn = "workingDir") {
11
11
$allFiles = @ ($allFiles )
12
12
}
13
13
14
-
15
-
16
- if ([string ]$argIndexes -match ' ^[0-9]+$' `
17
- -and ([string ]$argIndexes ).Length -gt 1 `
18
- -and ($allFiles.length -lt 11 -or [int ][string ]$argIndexes -ge $allFiles.length )
14
+ if ([string ]$argIndexes -match ' ^([0-9]+)(?: (\D+))?$' `
15
+ -and ($Matches [0 ].Length -gt 1 ) `
16
+ -and ($allFiles.length -lt 11 -or [int ]$Matches [0 ] -ge $allFiles.length )
19
17
) {
20
18
# Add by many 1 digit indexes (ex: 035 == 0, 3 and 5)
21
- $argIndexes = ([string ]$argIndexes ).ToCharArray()
19
+ $argIndexes = $Matches [1 ].ToCharArray()
20
+ $commitMsg = $Matches [2 ]
22
21
}
23
22
24
23
$indexes = @ ()
25
- foreach ($arg in $argIndexes ) {
26
- $index = $null ;
24
+ for ($counter = 0 ; $counter -lt $argIndexes.Length ; $counter ++ ) {
25
+ $arg = $argIndexes [$counter ]
26
+ $index = $null ; # Initialization for [ref] usage below (CI complains otherwise)
27
27
28
28
if ($arg -match ' ^\d+-\d+$' ) {
29
29
# Add by range (ex: 3-5)
@@ -49,18 +49,32 @@ function Parse-GitIndexes($argIndexes, $lookIn = "workingDir") {
49
49
# Add by index (ex: 3, 15)
50
50
$indexes += $index
51
51
52
+ } elseif ($argIndexes.Length -gt 1 -and $argIndexes.Length -eq $counter + 1 ) {
53
+ # Last argument: commit message
54
+ $commitMsg = $arg
55
+
52
56
} else {
53
57
Write-Host " Unparseable argument '$arg '" - ForegroundColor DarkMagenta
54
58
}
55
59
}
56
60
57
- return $indexes | % { $_ } | ? {
61
+ $ return = $indexes | ? {
58
62
if ($_ -ge $allFiles.length ) {
59
63
Write-Host " $_ is outside of the boundaries of Git-NumberedStatus (Length: $ ( $allFiles.length ) )" - ForegroundColor DarkMagenta
60
64
return $false
61
65
}
62
66
return $true
63
67
} | % { $allFiles [$_ ] }
68
+
69
+ if ($commitMsg ) {
70
+ if ($return -is [array ]) {
71
+ $return += $commitMsg
72
+ } else {
73
+ $return = $return , $commitMsg
74
+ }
75
+ }
76
+
77
+ return $return
64
78
}
65
79
66
80
0 commit comments