Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Get branch from status if possible

  • Loading branch information...
commit 0f1a1e04c22f418e3f26d4b8b67bed150ae0aee4 1 parent 54c38a3
@dahlbyk authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 GitUtils.ps1
View
5 GitUtils.ps1
@@ -74,8 +74,7 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
if ($enabled -and $gitDir)
{
$sw = [Diagnostics.Stopwatch]::StartNew()
- $branch = Get-GitBranch $gitDir $sw
- dbg 'Got branch' $sw
+ $branch = $null
$aheadBy = 0
$behindBy = 0
$indexAdded = @()
@@ -118,6 +117,7 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
}
'^## (?<branch>\S+)(?:\.\.\.(?<upstream>\S+) \[(?:ahead (?<ahead>\d+))?(?:, )?(?:behind (?<behind>\d+))?\])?$' {
+ $branch = $matches['branch']
$upstream = $matches['upstream']
$aheadBy = [int]$matches['ahead']
$behindBy = [int]$matches['behind']
@@ -126,6 +126,7 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
}
}
+ if(!$branch) { $branch = Get-GitBranch $gitDir $sw }
dbg 'Building status object' $sw
$indexPaths = $indexAdded + $indexModified + $indexDeleted + $indexUnmerged
$workingPaths = $filesAdded + $filesModified + $filesDeleted + $filesUnmerged
Please sign in to comment.
Something went wrong with that request. Please try again.