dotnet-installer/tools/sdk-readme-table-generator/TableGenerator/Shared.fs

46 lines
1.3 KiB
Forth
Raw Normal View History

module TableGenerator.Shared
open NuGet.Versioning
open System
type Branch =
{ GitBranchName: string
DisplayName: string
2021-03-02 15:19:31 +00:00
AkaMsChannel: string option }
type ReferenceTemplate =
{ AkaMSTemplate: string
2021-03-01 21:05:56 +00:00
LegacyTemplate: string
AkaMSLegacyTemplate: string}
let branchNameShorten (branch: Branch): string =
branch.GitBranchName.Substring(branch.GitBranchName.IndexOf('/') + 1).Replace("xx", "XX")
type BranchMajorMinorVersion =
{ Major: int
Minor: int
Patch: int
Release: string}
type BranchMajorMinorVersionOrmain =
| Main
| MajorMinor of BranchMajorMinorVersion
| NoVersion
let getMajorMinor (branch: Branch): BranchMajorMinorVersionOrmain =
match branch.GitBranchName = "main" with
| true -> Main
| _ ->
match branch.GitBranchName.IndexOf('/') with
| index when index < 0 -> NoVersion
| _ ->
match NuGetVersion.TryParseStrict
(branch.GitBranchName.Substring(branch.GitBranchName.IndexOf('/') + 1).Replace("xx", "99")) with
| true, version ->
MajorMinor
{ Major = version.Major
Minor = version.Minor
Patch = version.Patch
Release = version.Release}
| _ -> NoVersion