Skip to content

Commit cf64a98

Browse files
committed
fixes #1403 - getBranchName works language independent
1 parent f3f230f commit cf64a98

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/app/FakeLib/Git/Information.fs

+4-8
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,13 @@ let isGitVersionHigherOrEqual referenceVersion =
3535
/// Gets the git branch name
3636
let getBranchName repositoryDir =
3737
try
38-
let ok,msg,errors = runGitCommand repositoryDir "status"
38+
let ok,msg,errors = runGitCommand repositoryDir "status -s -b"
3939
let s = msg |> Seq.head
40-
41-
let mutable replaceBranchString = "On branch "
42-
let mutable replaceNoBranchString = "Not currently on any branch."
40+
41+
let replaceNoBranchString = "## HEAD ("
4342
let noBranch = "NoBranch"
4443

45-
if isGitVersionHigherOrEqual "1.9" then replaceNoBranchString <- "HEAD detached"
46-
if not <| isGitVersionHigherOrEqual "1.9" then replaceBranchString <- "# " + replaceBranchString
47-
48-
if startsWith replaceNoBranchString s then noBranch else s.Replace(replaceBranchString,"")
44+
if startsWith replaceNoBranchString s then noBranch else s.Substring(3)
4945
with _ when (repositoryDir = "" || repositoryDir = ".") && buildServer = TeamFoundation ->
5046
match environVarOrNone "BUILD_SOURCEBRANCHNAME" with
5147
| None -> reraise()

0 commit comments

Comments
 (0)