-
-
Notifications
You must be signed in to change notification settings - Fork 809
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
Use GitStatusCache when it's installed. #208
Changes from 1 commit
c6f759c
f970bd6
e032b91
92a5562
2d3cf04
cf1b9bc
6bafdd4
909b3bd
0551a36
caed8f3
002df86
008836e
49bb147
0febf54
2f13488
b90f7df
675299a
03131e1
3e13ee8
6c53ac1
600a390
4735df7
b07bce5
25a4c61
8e1aada
2b202c0
05015b9
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 |
---|---|---|
|
@@ -159,13 +159,19 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) { | |
|
||
$indexAdded.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.IndexAdded)))) | ||
$indexModified.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.IndexModified)))) | ||
$indexModified.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.IndexRenamed | Select-Object -ExpandProperty Old)))) | ||
$indexRenamedOld = $cacheResponse.IndexRenamed.Old | ||
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. I just learned that you could do this today; what is this trick called (for search purposes)? It returns either null (zero paths), a string (one path), or an object[] (many paths). 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. Member enumeration but it is only available in PS v3 and higher. To make that work on PS v2, use: $indexRenamedOld = foreach ($obj in $cacheResponse.IndexRenamed) { $obj.Old } The above is a bit faster than both Select-Object and Foreach-Object and shouldn't mess with the type. 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. Drat. I'm reverting back to the initial foreach and add version for the renamed files as I don't see a way to use the AddRange version without doing more enumerations (extracting the property then casting from objects to strings). (Recall the earlier version with Select-Object didn't work due to Select-Object's return type.) Please feel free to make additional tweaks if there's a faster approach. 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. I'm content with this. |
||
if ($indexRenamedOld) { | ||
$indexModified.AddRange($castStringSeq.Invoke($null, (,@($indexRenamedOld)))) | ||
} | ||
$indexDeleted.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.IndexDeleted)))) | ||
$indexUnmerged.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.Conflicted)))) | ||
|
||
$filesAdded.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.WorkingAdded)))) | ||
$filesModified.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.WorkingModified)))) | ||
$filesModified.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.WorkingRenamed | Select-Object -ExpandProperty Old)))) | ||
$workingRenamedOld = $cacheResponse.WorkingRenamed.Old | ||
if ($workingRenamedOld) { | ||
$filesModified.AddRange($castStringSeq.Invoke($null, (,@($workingRenamedOld)))) | ||
} | ||
$filesDeleted.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.WorkingDeleted)))) | ||
$filesUnmerged.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.Conflicted)))) | ||
|
||
|
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.
Cast was choking on the System.Management.Automation.PSObject returned by Select-Object.