Skip to content

Commit

Permalink
5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fosskers committed Apr 15, 2021
1 parent 4b17dc9 commit 249bd29
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup GHC
uses: actions/[email protected]
with:
ghc-version: "8.10.3"
ghc-version: "8.10.4"
enable-stack: true

- name: Clone project
Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 10 additions & 2 deletions Data/Versions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

-- |
-- Module : Data.Versions
-- Copyright : (c) Colin Woodbury, 2015 - 2020
-- Copyright : (c) Colin Woodbury, 2015 - 2021
-- License : BSD3
-- Maintainer: Colin Woodbury <[email protected]>
--
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 #-}
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion versions.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,6 +19,8 @@ description:
Please switch to <http://semver.org Semantic Versioning> 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
Expand Down

0 comments on commit 249bd29

Please sign in to comment.