Skip to content

Commit

Permalink
Make HEAD parsing aware of refs
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed Jan 21, 2011
1 parent 6cea2f4 commit 204ec45
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions GitUtils.ps1
Expand Up @@ -42,15 +42,16 @@ function Get-GitBranch($gitDir = $(Get-GitDirectory), [Diagnostics.Stopwatch]$sw
Coalesce-Args `
{ dbg 'Trying describe' $sw; git describe --exact-match HEAD 2>$null } `
{
dbg 'Falling back on SHA' $sw
dbg 'Falling back on parsing HEAD' $sw
$ref = Get-Content $gitDir\HEAD 2>$null
if ($ref -and $ref.Length -ge 7) {
if ($ref -match 'ref: (?<ref>.+)') {
return $Matches['ref']
} elseif ($ref -and $ref.Length -ge 7) {
return $ref.Substring(0,7)+'...'
} else {
return $null
return 'unknown'
}
} `
'unknown'
}
)
}

Expand Down

0 comments on commit 204ec45

Please sign in to comment.