Skip to content

Commit

Permalink
Backport some fixes from compiling with GHC 8.10 (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
f-f authored Feb 22, 2021
1 parent ff91075 commit 72315e0
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/Spago/Command/Ls.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ formatPackageNames = \case
formatPackageNamesJson :: [(PackageName, Package)] -> [Text]
formatPackageNamesJson pkgs =
let
asJson (PackageName{..}, Package{ location = loc@Remote{..}, ..})
asJson (PackageName{..}, Package{ location = loc@Remote{..} })
= JsonPackageOutput
{ json_packageName = packageName
, json_repo = toJSON loc
, json_version = version
}
asJson (PackageName{..}, Package { location = loc@Local{..}, ..})
asJson (PackageName{..}, Package { location = loc@(Local _), ..})
= JsonPackageOutput
{ json_packageName = packageName
, json_repo = toJSON loc
Expand Down
4 changes: 2 additions & 2 deletions src/Spago/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ parsePackage (Dhall.RecordLit ks') = do
let location = Remote{..}
pure Package{..}
parsePackage (Dhall.App
(Dhall.Field union (Dhall.FieldSelection { fieldSelectionLabel = "Local", ..}))
(Dhall.Field union (Dhall.FieldSelection { fieldSelectionLabel = "Local" }))
(Dhall.TextLit (Dhall.Chunks [] spagoConfigPath)))
| isLocationType union = do
localPath <- case Text.isSuffixOf "/spago.dhall" spagoConfigPath of
Expand Down Expand Up @@ -272,7 +272,7 @@ migrateBower Bower.PackageMeta{..} PackageSet{..} = (packageName, dependencies)
Nothing -> Left $ NonPureScript name
Just packageSetName | package <- PackageName packageSetName -> case Map.lookup package packagesDB of
Nothing -> Left $ MissingFromTheSet package
Just Package{ location = Local {..} } -> Right package
Just Package{ location = Local _ } -> Right package
Just Package{ location = Remote {..} } -> case SemVer.parseSemVer version of
Right v | SemVer.matches range v -> Right package
_ -> Left $ WrongVersion package range version
Expand Down
8 changes: 4 additions & 4 deletions src/Spago/FetchPackage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ fetchPackage
. (HasLogFunc env, HasGlobalCache env)
=> GlobalCache.ReposMetadataV1 -> (PackageName, Package)
-> RIO env ()
fetchPackage _ (PackageName package, Package { location = Local{..}, .. }) =
fetchPackage _ (PackageName package, Package { location = Local{..} }) =
logInfo $ display $ Messages.foundLocalPackage package localPath
fetchPackage metadata pair@(packageName'@PackageName{..}, Package{ location = Remote{..}, .. } ) = do
fetchPackage metadata pair@(packageName'@PackageName{..}, Package{ location = Remote{..} } ) = do
logDebug $ "Fetching package " <> display packageName
GlobalCache globalCacheDir cacheFlag <- view (the @GlobalCache)
let useGlobalCache = cacheFlag /= Just SkipCache
Expand Down Expand Up @@ -194,9 +194,9 @@ getPackageDir PackageName{..} version = Text.unpack packageName <> "/" <> Text.u
-- If the package is from a remote git repo, return the folder inside the local cache
-- Otherwise return the local folder
getLocalCacheDir :: (PackageName, Package) -> FilePath.FilePath
getLocalCacheDir (packageName, Package{ location = Remote{..}, .. }) = do
getLocalCacheDir (packageName, Package{ location = Remote{..} }) = do
localCacheDir <> "/" <> getPackageDir packageName version
getLocalCacheDir (_, Package{ location = Local{..}, .. }) =
getLocalCacheDir (_, Package{ location = Local{..} }) =
Text.unpack localPath


Expand Down
7 changes: 0 additions & 7 deletions src/Spago/PackageSet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,8 @@ updatePackageSetVersion maybeTag = do
, directory = Dhall.Directory
{ components = [ currentTag, "download", "releases", repo, org ]}
}
, ..
}
, ..
}
, ..
} = [(org, repo, currentTag)]
getCurrentTag _ = []

Expand All @@ -177,11 +174,9 @@ updatePackageSetVersion maybeTag = do
{ file = "packages.dhall"
, directory = Dhall.Directory
{ components = [ _currentTag, "download", "releases", upgradeRepo, upgradeOrg ]}
, ..
}
, ..
}
, ..
}
, ..
}) | upgradeRepo == repo && upgradeOrg == org =
Expand Down Expand Up @@ -234,9 +229,7 @@ isRemoteFrozen (Dhall.Import
{ importHashed = Dhall.ImportHashed
{ importType = Dhall.Remote _
, hash
, ..
}
, ..
}) = [isJust hash]
isRemoteFrozen _ = []

Expand Down
2 changes: 1 addition & 1 deletion src/Spago/Purs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ docs format sourcePaths = do
pursVersion :: RIO env (Either Text Version.SemVer)
pursVersion = Turtle.Bytes.shellStrictWithErr (purs <> " --version") empty >>= \case
(ExitSuccess, out, _err) -> do
let versionText = headMay $ Text.split (== ' ') (Text.Encoding.decodeUtf8With lenientDecode out)
let versionText = headMay $ Text.split (== ' ') (Text.strip $ Text.Encoding.decodeUtf8With lenientDecode out)
parsed = versionText >>= (hush . Version.semver)

pure $ case parsed of
Expand Down
1 change: 1 addition & 0 deletions test/BumpVersionSpec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE OverloadedLists #-}
module BumpVersionSpec (spec) where

import Data.Versions (SemVer (..), VUnit (..))
Expand Down
6 changes: 1 addition & 5 deletions test/SpagoSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import qualified Data.Text as Text
import Prelude hiding (FilePath)
import qualified System.IO.Temp as Temp
import Test.Hspec (Spec, around_, describe, it, shouldBe, shouldNotSatisfy,
shouldReturn, shouldSatisfy)
shouldNotBe, shouldReturn, shouldSatisfy)
import Turtle (ExitCode (..), cd, cp, decodeString, empty, encodeString,
mkdir, mktree, mv, pwd, readTextFile, rm, shell,
shellStrictWithErr, testdir, writeTextFile, (</>))
Expand Down Expand Up @@ -607,9 +607,6 @@ spec = around_ setup $ do
newPackages <- Text.strip <$> readTextFile "packages.dhall"
newPackages `shouldBe` packageSetUrl

{-
-- Note: this is commented because of https://github.com/purescript/spago/issues/685#issuecomment-694342262
it "Spago should migrate a package set from an alternative repository from src/packages.dhall" $ do

spago ["init"] >>= shouldBeSuccess
Expand All @@ -618,7 +615,6 @@ spec = around_ setup $ do
newPackages <- Text.strip <$> readTextFile "packages.dhall"
newPackages `shouldNotBe` "https://github.com/purerl/package-sets/releases/download/erl-0.13.6-20200713/packages.dhall"
newPackages `shouldSatisfy` Text.isPrefixOf "https://github.com/purerl/package-sets/releases/download"
-}

it "Spago should migrate package-set from src/packages.dhall to the user-specified one if it exists" $ do
-- initialize the project, so that it uses latest package set release
Expand Down

0 comments on commit 72315e0

Please sign in to comment.