Skip to content

Commit

Permalink
Merge pull request #759 from cmarcusreid/cacheError
Browse files Browse the repository at this point in the history
Put 'CACHE ERROR' in prompt when cache returns failure.
  • Loading branch information
dahlbyk authored Apr 8, 2020
2 parents 1a49d26 + 70daa28 commit a160c9a
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions src/GitUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -252,32 +252,42 @@ function Get-GitStatus {
if ($settings.EnableFileStatusFromCache) {
dbg 'Getting status from cache' $sw
$cacheResponse = Get-GitStatusFromCache
dbg 'Parsing status' $sw

$indexAdded.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.IndexAdded))))
$indexModified.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.IndexModified))))
foreach ($indexRenamed in $cacheResponse.IndexRenamed) {
$indexModified.Add($indexRenamed.Old)
if ($cacheResponse.Error) {
# git-status-cache failed; set $global:GitStatusCacheLoggingEnabled = $true, call Restart-GitStatusCache,
# and check %temp%\GitStatusCache_[timestamp].log for details.
dbg "Cache returned an error: $($cacheResponse.Error)" $sw
$branch = "CACHE ERROR"
$behindBy = 1
}
$indexDeleted.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.IndexDeleted))))
$indexUnmerged.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.Conflicted))))
else {
dbg 'Parsing status' $sw

$filesAdded.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.WorkingAdded))))
$filesModified.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.WorkingModified))))
foreach ($workingRenamed in $cacheResponse.WorkingRenamed) {
$filesModified.Add($workingRenamed.Old)
}
$filesDeleted.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.WorkingDeleted))))
$filesUnmerged.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.Conflicted))))
$indexAdded.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.IndexAdded))))
$indexModified.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.IndexModified))))
foreach ($indexRenamed in $cacheResponse.IndexRenamed) {
$indexModified.Add($indexRenamed.Old)
}
$indexDeleted.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.IndexDeleted))))
$indexUnmerged.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.Conflicted))))

$branch = $cacheResponse.Branch
$upstream = $cacheResponse.Upstream
$gone = $cacheResponse.UpstreamGone
$aheadBy = $cacheResponse.AheadBy
$behindBy = $cacheResponse.BehindBy
$filesAdded.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.WorkingAdded))))
$filesModified.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.WorkingModified))))
foreach ($workingRenamed in $cacheResponse.WorkingRenamed) {
$filesModified.Add($workingRenamed.Old)
}
$filesDeleted.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.WorkingDeleted))))
$filesUnmerged.AddRange($castStringSeq.Invoke($null, (,@($cacheResponse.Conflicted))))

$branch = $cacheResponse.Branch
$upstream = $cacheResponse.Upstream
$gone = $cacheResponse.UpstreamGone
$aheadBy = $cacheResponse.AheadBy
$behindBy = $cacheResponse.BehindBy

if ($cacheResponse.Stashes) { $stashCount = $cacheResponse.Stashes.Length }
if ($cacheResponse.State) { $branch += "|" + $cacheResponse.State }
if ($cacheResponse.Stashes) { $stashCount = $cacheResponse.Stashes.Length }
if ($cacheResponse.State) { $branch += "|" + $cacheResponse.State }
}
}
else {
dbg 'Getting status' $sw
Expand Down

0 comments on commit a160c9a

Please sign in to comment.