Skip to content

Commit bccfc5f

Browse files
Moved ignoreCheck inside checkSDistTarball
1 parent f7275f8 commit bccfc5f

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/Stack/SDist.hs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,20 @@ dirsFromFiles dirs = Set.toAscList (Set.delete "." results)
336336
--
337337
-- Note that we temporarily decompress the archive to analyze it.
338338
checkSDistTarball :: (StackM env m, HasEnvConfig env, MonadBaseUnlift IO m)
339-
=> Path Abs File -- ^ Absolute path to tarball
339+
=> SDistOpts -- ^ The configuration of what to check
340+
-> Path Abs File -- ^ Absolute path to tarball
340341
-> m ()
341-
checkSDistTarball tarball = withTempTarGzContents tarball $ \pkgDir' -> do
342+
checkSDistTarball opts tarball = withTempTarGzContents tarball $ \pkgDir' -> do
342343
pkgDir <- (pkgDir' </>) `liftM`
343344
(parseRelDir . FP.takeBaseName . FP.takeBaseName . toFilePath $ tarball)
344345
-- ^ drop ".tar" ^ drop ".gz"
346+
buildExtractedTarball pkgDir
347+
unless (sdoptsIgnoreCheck opts) (checkPackageInExtractedTarball pkgDir)
348+
349+
checkPackageInExtractedTarball :: (StackM env m, HasEnvConfig env, MonadBaseUnlift IO m)
350+
=> Path Abs Dir -- ^ Absolute path to tarball
351+
-> m ()
352+
checkPackageInExtractedTarball pkgDir = do
345353
cabalfp <- findOrGenerateCabalFile pkgDir
346354
name <- parsePackageNameFromFilePath cabalfp
347355
config <- getDefaultPackageConfig
@@ -405,13 +413,14 @@ buildExtractedTarball pkgDir = do
405413
-- | Version of 'checkSDistTarball' that first saves lazy bytestring to
406414
-- temporary directory and then calls 'checkSDistTarball' on it.
407415
checkSDistTarball' :: (StackM env m, HasEnvConfig env, MonadBaseUnlift IO m)
408-
=> String -- ^ Tarball name
416+
=> SDistOpts
417+
-> String -- ^ Tarball name
409418
-> L.ByteString -- ^ Tarball contents as a byte string
410419
-> m ()
411-
checkSDistTarball' name bytes = withSystemTempDir "stack" $ \tpath -> do
420+
checkSDistTarball' opts name bytes = withSystemTempDir "stack" $ \tpath -> do
412421
npath <- (tpath </>) `liftM` parseRelFile name
413422
liftIO $ L.writeFile (toFilePath npath) bytes
414-
checkSDistTarball npath
423+
checkSDistTarball opts npath
415424

416425
withTempTarGzContents :: (MonadIO m, MonadMask m)
417426
=> Path Abs File -- ^ Location of tarball

src/main/Main.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,7 @@ uploadCmd sdistOpts go = do
674674
withBuildConfigAndLock go $ \_ -> do
675675
config <- view configL
676676
getCreds <- liftIO (runOnce (Upload.loadCreds config))
677-
unless (sdoptsIgnoreCheck sdistOpts) $
678-
mapM_ (resolveFile' >=> checkSDistTarball) files
677+
mapM_ (resolveFile' >=> checkSDistTarball sdistOpts) files
679678
forM_
680679
files
681680
(\file ->
@@ -693,7 +692,7 @@ uploadCmd sdistOpts go = do
693692
forM_ dirs $ \dir -> do
694693
pkgDir <- resolveDir' dir
695694
(tarName, tarBytes, mcabalRevision) <- getSDistTarball (sdoptsPvpBounds sdistOpts) pkgDir
696-
unless (sdoptsIgnoreCheck sdistOpts) $ checkSDistTarball' tarName tarBytes
695+
checkSDistTarball' sdistOpts tarName tarBytes
697696
liftIO $ do
698697
creds <- getCreds
699698
Upload.uploadBytes creds tarName tarBytes
@@ -720,7 +719,7 @@ sdistCmd sdistOpts go =
720719
tarPath <- (distDir </>) <$> parseRelFile tarName
721720
ensureDir (parent tarPath)
722721
liftIO $ L.writeFile (toFilePath tarPath) tarBytes
723-
unless (sdoptsIgnoreCheck sdistOpts) (checkSDistTarball tarPath)
722+
checkSDistTarball sdistOpts tarPath
724723
$logInfo $ "Wrote sdist tarball to " <> T.pack (toFilePath tarPath)
725724
when (sdoptsSign sdistOpts) (void $ Sig.sign (sdoptsSignServerUrl sdistOpts) tarPath)
726725

0 commit comments

Comments
 (0)