Files
postgrest/src/PostgREST/Version.hs
T
Wolfgang WaltherandMichal Kleczek a5cc457875 chore(deps): update hasql to 1.9.3.1
Michael and I arrived at mostly the same things independently. Took some
of his, some of mine.

Co-authored-by: Michal Kleczek <michal@kleczek.org>
2026-04-27 09:12:31 +00:00

42 lines
1.1 KiB
Haskell

{-# LANGUAGE CPP #-}
module PostgREST.Version
( docsVersion
, prettyVersion
) where
import qualified Data.Text as T
import Protolude
-- Somehow this is not defined in doctests, so when running them
-- on a file that includes Version.hs, compilation fails.
#ifndef VERSION_postgrest
#define VERSION_postgrest "0"
#endif
version :: [Text]
version = T.splitOn "." VERSION_postgrest
-- | User friendly version number such as '14.0'.
-- Pre-release versions are tagged as such, e.g., '15 (pre-release)'.
prettyVersion :: ByteString
prettyVersion =
(encodeUtf8 . T.intercalate "." $ take 2 version) <> preRelease
where
preRelease = if isPreRelease then " (pre-release)" else mempty
-- | Version number used in docs.
-- Pre-release versions link to the latest docs
-- Uses only the first component of the version. Example: 'v1'
docsVersion :: Text
docsVersion
| isPreRelease = "latest"
| otherwise = "v" <> T.intercalate "." (take 1 version)
-- | Versions with one components (e.g., '15') are treated as pre-releases.
isPreRelease :: Bool
isPreRelease =
length version == 1