From 249bd2964606e62d01a78f4ce0c53cc6dc42c168 Mon Sep 17 00:00:00 2001 From: Colin Woodbury Date: Wed, 14 Apr 2021 20:23:06 -0700 Subject: [PATCH] 5.0.0 --- .github/workflows/ci.yaml | 2 +- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ Data/Versions.hs | 12 ++++++++++-- versions.cabal | 4 +++- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ecb6f02..4f41b78 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,7 +13,7 @@ jobs: - name: Setup GHC uses: actions/setup-haskell@v1.1.4 with: - ghc-version: "8.10.3" + ghc-version: "8.10.4" enable-stack: true - name: Clone project diff --git a/CHANGELOG.md b/CHANGELOG.md index ebca02a..6a34f90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## 5.0.0 (2021-04-14) + +This release brings `versions` in line with version `2.0.0` of the SemVer spec. +The main addition to the spec is the allowance of hyphens in both the prerelease +and metadata sections. As such, **certain versions like `1.2.3+1-1` which +previously would not parse as SemVer now do.** + +To accomodate this and other small spec updates, the `SemVer` and `Version` +types have received breaking changes here. + +#### Changed + +- **Breaking:** The `_svMeta` field of `SemVer` is now parsed as a dumber `Maybe + Text` instead of `[VChunk]`, due to metadata now being allowed to possess + leading zeroes. +- **Breaking:** Like the above, the `_vMeta` field of `Version` is now `Maybe Text`. +- **Breaking: The `_vRel` and `_vMeta` fields of `Version` have had their order + flipped.** Further, the prelease and meta sections are now expected in the + same order as `SemVer` when parsing (prerel first, meta second). `Version` is + thus now a quite similar to `SemVer`, except allowing letters in more + permissive positions. +- **Breaking:** The `meta` traversal has been altered to accomodate the metadata + field changes. + +#### Fixed + +- Parsing certain legal SemVers specified in the spec. + ## 4.0.3 (2021-02-23) #### Changed diff --git a/Data/Versions.hs b/Data/Versions.hs index 20cff32..f35164a 100644 --- a/Data/Versions.hs +++ b/Data/Versions.hs @@ -7,7 +7,7 @@ -- | -- Module : Data.Versions --- Copyright : (c) Colin Woodbury, 2015 - 2020 +-- Copyright : (c) Colin Woodbury, 2015 - 2021 -- License : BSD3 -- Maintainer: Colin Woodbury -- @@ -29,6 +29,8 @@ -- currently using it. It provides consistency in version incrementing and has -- the best constraints on comparisons. -- +-- __This library implements version @2.0.0@ of the SemVer spec.__ +-- -- == Using the Parsers -- In general, `versioning` is the function you want. It attempts to parse a -- given `Text` using the three individual parsers, `semver`, `version` and @@ -250,16 +252,19 @@ _Mess :: Traversal' Text Mess _Mess f t = either (const (pure t)) (fmap prettyMess . f) $ mess t {-# INLINE _Mess #-} +-- | Possibly extract a `SemVer` from a `Versioning`. _Ideal :: Traversal' Versioning SemVer _Ideal f (Ideal s) = Ideal <$> f s _Ideal _ v = pure v {-# INLINE _Ideal #-} +-- | Possibly extract a `Version` from a `Versioning`. _General :: Traversal' Versioning Version _General f (General v) = General <$> f v _General _ v = pure v {-# INLINE _General #-} +-- | Possibly extract a `Mess` from a `Versioning`. _Complex :: Traversal' Versioning Mess _Complex f (Complex m) = Complex <$> f m _Complex _ v = pure v @@ -422,11 +427,13 @@ digits = Digits str :: Text -> Maybe VUnit str t = bool Nothing (Just $ Str t) $ T.all isAlpha t +-- | Possibly traverse the inner digit value of a `VUnit`. _Digits :: Traversal' VUnit Word _Digits f (Digits i) = Digits <$> f i _Digits _ v = pure v {-# INLINE _Digits #-} +-- | Possibly traverse the inner text of a `VUnit`. _Str :: Traversal' VUnit Text _Str f (Str t) = Str . (\t' -> bool t t' (T.all isAlpha t')) <$> f t _Str _ v = pure v @@ -611,6 +618,7 @@ instance Semantic Version where semantic _ v = pure v {-# INLINE semantic #-} +-- | A `Version`'s inner epoch `Word`. epoch :: Lens' Version (Maybe Word) epoch f v = fmap (\ve -> v { _vEpoch = ve }) (f $ _vEpoch v) {-# INLINE epoch #-} @@ -738,7 +746,7 @@ data VSep = VColon | VHyphen | VPlus | VUnder -------------------------------------------------------------------------------- -- Parsing --- | A synonym for the more verbose `megaparsec` error type. +-- | A synonym for the more verbose 'megaparsec' error type. type ParsingError = ParseErrorBundle Text Void -- | Parse a piece of `Text` into either an (Ideal) `SemVer`, a (General) diff --git a/versions.cabal b/versions.cabal index b5b54e3..8b28d8a 100644 --- a/versions.cabal +++ b/versions.cabal @@ -1,6 +1,6 @@ cabal-version: 2.2 name: versions -version: 4.0.3 +version: 5.0.0 synopsis: Types and parsers for software version numbers. description: A library for parsing and comparing software version numbers. We like to give @@ -19,6 +19,8 @@ description: Please switch to if you aren't currently using it. It provides consistency in version incrementing and has the best constraints on comparisons. + . + This library implements version @2.0.0@ of the SemVer spec. category: Data homepage: https://github.com/fosskers/versions