Permalink
Browse files

Don't declare versions as incompatible with the attrpath unless the p…

…revious version was compatible

closes #88
  • Loading branch information...
ryantm committed Nov 18, 2018
1 parent dfec129 commit ef133fccfe61726efb128c77d46f67389fe72e52
Showing with 15 additions and 9 deletions.
  1. +4 −2 src/Update.hs
  2. +11 −7 src/Utils.hs
@@ -43,7 +43,8 @@ import Utils
, Version
, branchName
, canFail
, checkAttrPathVersion
, versionCompatibleWithPathPin
, versionIncompatibleWithPathPin
, eitherToError
, orElse
, ourShell
@@ -145,7 +146,8 @@ updatePackage log updateEnv mergeBaseOutpathsContext = do
[ ShellyHandler (\(ex :: ExitCode) -> throw ex)
, ShellyHandler (\(ex :: SomeException) -> errorExit (T.pack (show ex)))
] $ do
unless (checkAttrPathVersion attrPath (newVersion updateEnv)) $
when (versionCompatibleWithPathPin attrPath (oldVersion updateEnv) &&
versionIncompatibleWithPathPin attrPath (newVersion updateEnv)) $
errorExit
("Version in attr path " <> attrPath <> " not compatible with " <>
newVersion updateEnv)
@@ -7,7 +7,8 @@ module Utils
, Version
, UpdateEnv(..)
, canFail
, checkAttrPathVersion
, versionCompatibleWithPathPin
, versionIncompatibleWithPathPin
, orElse
, setupNixpkgs
, tRead
@@ -149,19 +150,19 @@ clearBreakOn boundary string =
--
-- Examples:
--
-- >>> checkAttrPathVersion "libgit2_0_25" "0.25.3"
-- >>> versionCompatibleWithPathPin "libgit2_0_25" "0.25.3"
-- True
--
-- >>> checkAttrPathVersion "owncloud90" "9.0.3"
-- >>> versionCompatibleWithPathPin "owncloud90" "9.0.3"
-- True
--
-- >>> checkAttrPathVersion "owncloud-client" "2.4.1"
-- >>> versionCompatibleWithPathPin "owncloud-client" "2.4.1"
-- True
--
-- >>> checkAttrPathVersion "owncloud90" "9.1.3"
-- >>> versionCompatibleWithPathPin "owncloud90" "9.1.3"
-- False
checkAttrPathVersion :: Text -> Version -> Bool
checkAttrPathVersion attrPath newVersion =
versionCompatibleWithPathPin :: Text -> Version -> Bool
versionCompatibleWithPathPin attrPath newVersion =
if "_" `T.isInfixOf` attrPath
then let attrVersionPart =
let (name, version) = clearBreakOn "_" attrPath
@@ -184,6 +185,9 @@ checkAttrPathVersion attrPath newVersion =
-- If we don't find version numbers in the attr path, exit success.
in maybe True (`T.isPrefixOf` noPeriodNewVersion) attrVersionPart

versionIncompatibleWithPathPin :: Text -> Version -> Bool
versionIncompatibleWithPathPin path version = not (versionCompatibleWithPathPin path version)

newtype ExitCode =
ExitCode Int
deriving (Show)

0 comments on commit ef133fc

Please sign in to comment.