Skip to content
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

Merged
merged 27 commits into from
Jan 15, 2017
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c6f759c
Use git-status-cache-posh-client to retrieve git informaiton when mod…
cmarcusreid Jul 27, 2015
f970bd6
Read conflicted files from cache response.
cmarcusreid Aug 7, 2015
e032b91
Add dbg calls for timing.
cmarcusreid Aug 10, 2015
92a5562
Update parsing for renamed files.
cmarcusreid Aug 11, 2015
2d3cf04
Delay computing EnableFileStatusFromCache setting until first request…
cmarcusreid Aug 19, 2015
cf1b9bc
Fix whitespace.
cmarcusreid Aug 19, 2015
6bafdd4
Fix incorrect brace style.
cmarcusreid Aug 25, 2015
909b3bd
Merge branch 'master' into useGitStatusCache
cmarcusreid Aug 25, 2015
0551a36
Merge branch 'master' into useGitStatusCache
cmarcusreid Aug 28, 2015
caed8f3
Merge branch 'master' into useGitStatusCache
cmarcusreid Aug 30, 2015
002df86
Merge branch 'master' into useGitStatusCache
cmarcusreid Sep 6, 2015
008836e
Read stash count from cache.
cmarcusreid Sep 6, 2015
49bb147
Merge branch 'master' into useGitStatusCache
cmarcusreid Sep 25, 2015
0febf54
Merge branch 'master' into useGitStatusCache
cmarcusreid Jan 10, 2016
2f13488
Merge branch 'master' into useGitStatusCache
cmarcusreid Mar 12, 2016
b90f7df
Reformat
dahlbyk Jan 2, 2017
675299a
Merge branch 'master' into git-status-cache
dahlbyk Jan 2, 2017
03131e1
Update cache response parsing to add to existing lists rather than ov…
cmarcusreid Jan 2, 2017
3e13ee8
Add cache responses to existing lists
dahlbyk Jan 2, 2017
6c53ac1
Revert accidental whitepsace add.
cmarcusreid Jan 2, 2017
600a390
Merge remote-tracking branch 'remotes/upstream/git-status-cache' into…
cmarcusreid Jan 2, 2017
4735df7
Merge branch 'master' into git-status-cache
dahlbyk Jan 4, 2017
b07bce5
Use efficient ConvertTo-StringSeq
dahlbyk Jan 4, 2017
25a4c61
Inline ConvertTo-StringSeq
dahlbyk Jan 7, 2017
8e1aada
Merge branch 'master' into git-status-cache
dahlbyk Jan 7, 2017
2b202c0
Fix cast break on PSObjects returned by Select-Object.
cmarcusreid Jan 14, 2017
05015b9
Remove member enumeration to support earlier versions of PowerShell.
cmarcusreid Jan 15, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions GitUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator Author

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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).

Copy link
Collaborator

@rkeithhill rkeithhill Jan 14, 2017

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

Copy link
Owner

Choose a reason for hiding this comment

The 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))))

Expand Down