Skip to content

Commit 97cd182

Browse files
Improve readability
1 parent 22b302c commit 97cd182

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Stack/Config.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,13 +792,18 @@ resolvePackageLocation menv projRoot (PLRemote url remotePackageType) = do
792792
throwM $ UnexpectedArchiveContents dirs files
793793
_ -> return dir
794794

795+
-- | Remove path from package entry. If the package entry contains subdirs, then it removes
796+
-- the subdir. If the package entry points to the path to remove, this function returns
797+
-- Nothing. If the package entry doesn't mention the path to remove, it is returned unchanged
795798
removePathFromPackageEntry
796799
:: (StackMiniM env m, HasConfig env)
797800
=> EnvOverride
798801
-> Path Abs Dir -- ^ project root
799802
-> Path Abs Dir -- ^ path to remove
800803
-> PackageEntry
801804
-> m (Maybe PackageEntry)
805+
-- ^ Nothing if the whole package entry should be removed, otherwise
806+
-- it returns the updated PackageEntry
802807
removePathFromPackageEntry menv projectRoot pathToRemove packageEntry = do
803808
locationPath <- resolvePackageLocation menv projectRoot (peLocation packageEntry)
804809
case peSubdirs packageEntry of

src/Stack/SDist.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ checkPackageInExtractedTarball pkgDir = do
375375

376376
buildExtractedTarball :: (StackM env m, HasEnvConfig env, MonadBaseUnlift IO m) => Path Abs Dir -> m ()
377377
buildExtractedTarball pkgDir = do
378-
newPackagesRef <- liftIO (newIORef Nothing)
379378
projectRoot <- view projectRootL
380379
envConfig <- view envConfigL
381380
menv <- getMinimalEnvOverride
@@ -385,6 +384,7 @@ buildExtractedTarball pkgDir = do
385384
resolvedEntry <- resolvePackageEntry menv projectRoot entry
386385
return $ fmap fst resolvedEntry
387386
allPackagePaths <- fmap mconcat (mapM getPaths packageEntries)
387+
-- We remove the path based on the name of the package
388388
let isPathToRemove path = do
389389
localPackage <- readLocalPackage path
390390
return $ packageName (lpPackage localPackage) == packageName (lpPackage localPackageToBuild)
@@ -394,6 +394,7 @@ buildExtractedTarball pkgDir = do
394394
return (catMaybes adjustedPackageEntries)
395395
entriesWithoutBuiltPackage <- foldM adjustPackageEntries packageEntries pathsToRemove
396396
let newEntry = PackageEntry Nothing (PLFilePath (toFilePath pkgDir)) []
397+
newPackagesRef <- liftIO (newIORef Nothing)
397398
let adjustEnvForBuild env =
398399
let updatedEnvConfig = envConfig
399400
{envConfigPackagesRef = newPackagesRef

0 commit comments

Comments
 (0)