2020-11-23 23:46:21 +00:00
|
|
|
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 }
|
2020-11-23 23:46:21 +00:00
|
|
|
|
|
|
|
type ReferenceTemplate =
|
|
|
|
{ AkaMSTemplate: string
|
2021-03-01 21:05:56 +00:00
|
|
|
LegacyTemplate: string
|
|
|
|
AkaMSLegacyTemplate: string}
|
2020-11-23 23:46:21 +00:00
|
|
|
|
|
|
|
let branchNameShorten (branch: Branch): string =
|
|
|
|
branch.GitBranchName.Substring(branch.GitBranchName.IndexOf('/') + 1).Replace("xx", "XX")
|
|
|
|
|
|
|
|
type BranchMajorMinorVersion =
|
|
|
|
{ Major: int
|
|
|
|
Minor: int
|
2020-12-15 11:57:44 +00:00
|
|
|
Patch: int
|
2020-11-23 23:46:21 +00:00
|
|
|
Release: string}
|
|
|
|
|
2021-03-25 23:06:50 +00:00
|
|
|
type BranchMajorMinorVersionOrmain =
|
2021-03-19 00:28:39 +00:00
|
|
|
| Main
|
2020-11-23 23:46:21 +00:00
|
|
|
| MajorMinor of BranchMajorMinorVersion
|
|
|
|
| NoVersion
|
|
|
|
|
2021-03-25 23:06:50 +00:00
|
|
|
let getMajorMinor (branch: Branch): BranchMajorMinorVersionOrmain =
|
|
|
|
match branch.GitBranchName = "main" with
|
2021-03-19 00:28:39 +00:00
|
|
|
| true -> Main
|
2020-11-23 23:46:21 +00:00
|
|
|
| _ ->
|
|
|
|
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
|
2020-12-15 11:57:44 +00:00
|
|
|
Patch = version.Patch
|
2020-11-23 23:46:21 +00:00
|
|
|
Release = version.Release}
|
|
|
|
| _ -> NoVersion
|