Skip to content

Commit

Permalink
Stop printing to stdout in mainline case (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
Smaug123 authored May 1, 2024
1 parent 5613329 commit f034e23
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions ApiSurface/MonotonicVersion.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ApiSurface
namespace ApiSurface

open System.IO
open System.Reflection
Expand Down Expand Up @@ -26,13 +26,7 @@ module MonotonicVersion =
let latestVersion = NuGetVersion (latestVersion.Major, latestVersion.Minor, 0)
let latestVersionStr = latestVersion.Version.ToString 2

if currentVersion >= latestVersion then
printfn
"Version of '%s' specified in version.json (%O) is >= the latest version in the NuGet repository (%s)"
packageId
currentVersion
latestVersionStr
else
if currentVersion < latestVersion then
[
sprintf
"Version of '%s' specified in version.json (%O) is less than the latest version in the NuGet repository (%s)"
Expand All @@ -59,16 +53,7 @@ module MonotonicVersion =
let latestVersion = NuGetVersion (latestVersion.Major, latestVersion.Minor, 0)
let latestVersionStr = latestVersion.Version.ToString 2

let acceptableMinorIncrease = minorDiff <= 1 && majorDiff = 0
let acceptableMajorIncrease = majorDiff <= 1 && minorDiff <= 0

if acceptableMajorIncrease || acceptableMinorIncrease then
printfn
"Version of '%s' specified in version.json (%O) is >= the latest version in the NuGet repository by an acceptable amount (%s)"
packageId
currentVersion
latestVersionStr
else
if majorDiff > 1 || minorDiff > 1 || (minorDiff > 0 && majorDiff <> 0) then
[
sprintf
"Version of '%s' specified in version.json (%O) is larger than the latest version in the NuGet repository (%s) by an unacceptable amount"
Expand All @@ -84,7 +69,7 @@ module MonotonicVersion =

/// Validate the specifically-named embedded resource that is a version.json file.
[<CompiledName "ValidateResource">]
let validateResource (resourceName : string) (assembly : Assembly) (packageId : string) =
let validateResource (resourceName : string) (assembly : Assembly) (packageId : string) : unit =
let resource = Assembly.tryReadEmbeddedResource assembly resourceName

match resource with
Expand All @@ -105,11 +90,6 @@ module MonotonicVersion =
|> Seq.map (fun s -> SourceRepository (s, Repository.Provider.GetCoreV3 ()))
|> Array.ofSeq

repos
|> Seq.map (fun x -> x.PackageSource.SourceUri.ToString ())
|> String.concat "\n"
|> printfn "Using the following NuGet repositories:\n%s"

let versions =
repos
|> Array.Parallel.collect (fun repo ->
Expand Down

0 comments on commit f034e23

Please sign in to comment.