Skip to content

Commit f6fda69

Browse files
committed
Re commercialhaskell#5955 Prettier runTemplateInits and fix logSticky
1 parent 98b36dd commit f6fda69

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/Network/HTTP/StackClient.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ verifiedDownloadWithProgress
188188
-> Maybe Int
189189
-> RIO env Bool
190190
verifiedDownloadWithProgress req destpath lbl msize =
191-
verifiedDownload req destpath (chattyDownloadProgress lbl msize)
191+
verifiedDownload req destpath (chattyDownloadProgress lbl msize)
192+
192193

193194
chattyDownloadProgress
194195
:: ( HasLogFunc env

src/Stack/New.hs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,18 @@ loadTemplate name logIt = do
355355
pure template
356356
else throwM $ PrettyException $
357357
LoadTemplateFailed name path
358+
358359
relSettings :: String -> Maybe TemplateDownloadSettings
359360
relSettings req = do
360361
rtp <- parseRepoPathWithService defaultRepoService (T.pack req)
361362
pure (settingsFromRepoTemplatePath rtp)
363+
362364
downloadFromUrl :: TemplateDownloadSettings -> Path Abs Dir -> RIO env Text
363365
downloadFromUrl settings templateDir = do
364366
let url = tplDownloadUrl settings
365367
rel = fromMaybe backupUrlRelPath (parseRelFile url)
366368
downloadTemplate url (tplExtract settings) (templateDir </> rel)
369+
367370
downloadTemplate :: String
368371
-> (ByteString
369372
-> Either String Text)
@@ -375,12 +378,15 @@ loadTemplate name logIt = do
375378
mkDownloadRequest (setRequestCheckStatus req)
376379
logIt RemoteTemp
377380
catch
378-
(void $ do
379-
verifiedDownloadWithProgress dReq path (T.pack $ toFilePath path) Nothing
381+
( do let label = T.pack $ toFilePath path
382+
res <- verifiedDownloadWithProgress dReq path label Nothing
383+
if res
384+
then logStickyDone ("Downloaded " <> display label <> ".")
385+
else logStickyDone "Already downloaded."
380386
)
381387
(useCachedVersionOrThrow url path)
382-
383388
loadLocalFile path extract
389+
384390
useCachedVersionOrThrow :: String
385391
-> Path Abs File
386392
-> VerifiedDownloadException
@@ -636,10 +642,16 @@ runTemplateInits dir = do
636642
config <- view configL
637643
case configScmInit config of
638644
Nothing -> pure ()
639-
Just Git ->
640-
withWorkingDir (toFilePath dir) $
641-
catchAny (proc "git" ["init"] runProcess_)
642-
(\_ -> logInfo "git init failed to run, ignoring ...")
645+
Just Git -> withWorkingDir (toFilePath dir) $
646+
catchAny
647+
(proc "git" ["init"] runProcess_)
648+
( \_ -> prettyWarn $
649+
fillSep
650+
[ flow "Stack failed to run a"
651+
, style Shell (flow "git init")
652+
, flow "command. Ignoring..."
653+
]
654+
)
643655

644656
-- | Display help for the templates command.
645657
templatesHelp :: HasLogFunc env => RIO env ()

0 commit comments

Comments
 (0)