From 7a66d56918d7f20c6517f5e9fa1b2904b08374d5 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Tue, 27 Jun 2017 19:43:06 +0300 Subject: [PATCH 1/2] Unpack by hash --- ChangeLog.md | 3 +++ src/Stack/Fetch.hs | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index bc1e52ad24..1673ea2ffd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -57,6 +57,9 @@ Other enhancements: * MinGW bin folder now is searched for dynamic libraries. See [#3126](https://github.com/commercialhaskell/stack/issues/3126) * When using Nix, nix-shell now depends always on git to prevent runtime errors while fetching metadata +* The `stack unpack` command now accepts a form where an explicit + Hackage revision hash is specified, e.g. `stack unpack + foo-1.2.3@gitsha1:deadbeef`. Bug fixes: diff --git a/src/Stack/Fetch.hs b/src/Stack/Fetch.hs index 7db9c15daa..1439d114ff 100644 --- a/src/Stack/Fetch.hs +++ b/src/Stack/Fetch.hs @@ -59,7 +59,7 @@ import Data.Monoid import Data.Set (Set) import qualified Data.Set as Set import qualified Data.Text as T -import Data.Text.Encoding (decodeUtf8) +import Data.Text.Encoding (encodeUtf8, decodeUtf8) import Data.Text.Metrics import Data.Typeable (Typeable) import Data.Word (Word64) @@ -146,7 +146,7 @@ unpackPackages mMiniBuildPlan dest input = do ([], x) -> return $ partitionEithers x (errs, _) -> throwM $ CouldNotParsePackageSelectors errs resolved <- resolvePackages mMiniBuildPlan - (Map.fromList $ map (, Nothing) idents) + (Map.fromList idents) (Set.fromList names) ToFetchResult toFetch alreadyUnpacked <- getToFetch (Just dest') resolved unless (Map.null alreadyUnpacked) $ @@ -165,8 +165,12 @@ unpackPackages mMiniBuildPlan dest input = do Right x -> Right $ Left x Left _ -> case parsePackageIdentifierFromString s of - Left _ -> Left s - Right x -> Right $ Right x + Right x -> Right $ Right (x, Nothing) + Left _ -> maybe (Left s) (Right . Right) $ do + (identS, '@':revisionS) <- return $ break (== '@') s + Right ident <- return $ parsePackageIdentifierFromString identS + hash <- T.stripPrefix "gitsha1:" $ T.pack revisionS + Just (ident, Just $ GitSHA1 $ encodeUtf8 hash) -- | Ensure that all of the given package idents are unpacked into the build -- unpack directory, and return the paths to all of the subdirectories. From 8b0d0879e15cd0599ed9c3290252f41f52ce5885 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Tue, 27 Jun 2017 21:03:28 +0300 Subject: [PATCH 2/2] Mark as experimental --- ChangeLog.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 1673ea2ffd..f5415505b9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -59,7 +59,9 @@ Other enhancements: while fetching metadata * The `stack unpack` command now accepts a form where an explicit Hackage revision hash is specified, e.g. `stack unpack - foo-1.2.3@gitsha1:deadbeef`. + foo-1.2.3@gitsha1:deadbeef`. Note that this should be considered + _experimental_, Stack will likely move towards a different hash + format in the future. Bug fixes: