Skip to content

Commit 1385c19

Browse files
KevinRansombaronfel
authored andcommitted
Handle git beta indicators
1 parent 3f49b07 commit 1385c19

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/fsharp/fsc.fs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,10 +837,20 @@ module MainModuleBuilder =
837837
v
838838

839839
let productVersionToILVersionInfo (version: string) : ILVersionInfo =
840-
let parseOrZero v = match System.UInt16.TryParse v with (true, i) -> i | (false, _) -> 0us
840+
let parseOrZero i (v:string) =
841+
let v =
842+
// When i = 3 then this is the 4th part of the version. The last part of the version can be trailed by any characters so we trim them off
843+
if i <> 3 then v
844+
else
845+
v |> Seq.fold(fun (finished, v) c -> match finished with
846+
| false when Char.IsDigit(c) -> false, v + c.ToString()
847+
| _ -> true, v) (false, "") |> snd
848+
match System.UInt16.TryParse v with
849+
| (true, i) -> i
850+
| (false, _) -> 0us
841851
let validParts =
842852
version.Split('.')
843-
|> Seq.map parseOrZero
853+
|> Array.mapi(fun i v -> parseOrZero i v)
844854
|> Seq.toList
845855
match validParts @ [0us; 0us; 0us; 0us] with
846856
| major :: minor :: build :: rev :: _ -> ILVersionInfo(major, minor, build, rev)

0 commit comments

Comments
 (0)