Skip to content

Commit 24db832

Browse files
committed
pretty up s/S/Upgrade
1 parent 961fac2 commit 24db832

1 file changed

Lines changed: 24 additions & 18 deletions

File tree

src/Stack/Upgrade.hs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import Stack.Build
2626
import Stack.Config
2727
import Stack.Fetch
2828
import Stack.PackageIndex
29+
import Stack.PrettyPrint
2930
import Stack.Setup
3031
import Stack.Types.PackageIdentifier
3132
import Stack.Types.PackageIndex
@@ -116,9 +117,11 @@ upgrade gConfigMonoid mresolver builtHash (UpgradeOpts mbo mso) =
116117
-- See #2977 - if --git or --git-repo is specified, do source upgrade.
117118
(_, Just so@(SourceOpts (Just _))) -> source so
118119
(Just bo, Just so) -> binary bo `catchAny` \e -> do
119-
logWarn "Exception occured when trying to perform binary upgrade:"
120-
logWarn $ T.pack $ show e
121-
logWarn "Falling back to source upgrade"
120+
prettyWarnL
121+
[ flow "Exception occured when trying to perform binary upgrade:"
122+
, fromString . show $ e
123+
, line <> flow "Falling back to source upgrade"
124+
]
122125

123126
source so
124127
where
@@ -141,28 +144,30 @@ binaryUpgrade (BinaryOpts mplatform force' mver morg mrepo) = do
141144
isNewer <-
142145
case mdownloadVersion of
143146
Nothing -> do
144-
logError "Unable to determine upstream version from Github metadata"
145-
unless force $
146-
logError "Rerun with --force-download to force an upgrade"
147+
prettyErrorL $
148+
flow "Unable to determine upstream version from Github metadata"
149+
:
150+
[ line <> flow "Rerun with --force-download to force an upgrade"
151+
| not force]
147152
return False
148153
Just downloadVersion -> do
149-
logInfo $ T.concat
150-
[ "Current Stack version: "
151-
, versionText stackVersion
152-
, ", available download version: "
153-
, versionText downloadVersion
154+
prettyInfoL
155+
[ flow "Current Stack version:"
156+
, display stackVersion <> ","
157+
, flow "available download version:"
158+
, display downloadVersion
154159
]
155160
return $ downloadVersion > stackVersion
156161

157162
toUpgrade <- case (force, isNewer) of
158163
(False, False) -> do
159-
logInfo "Skipping binary upgrade, you are already running the most recent version"
164+
prettyInfoS "Skipping binary upgrade, you are already running the most recent version"
160165
return False
161166
(True, False) -> do
162-
logInfo "Forcing binary upgrade"
167+
prettyInfoS "Forcing binary upgrade"
163168
return True
164169
(_, True) -> do
165-
logInfo "Newer version detected, downloading"
170+
prettyInfoS "Newer version detected, downloading"
166171
return True
167172
when toUpgrade $ do
168173
config <- view configL
@@ -191,16 +196,17 @@ sourceUpgrade gConfigMonoid mresolver builtHash (SourceOpts gitRepo) =
191196
[] -> throwString $ "No commits found for branch " ++ branch ++ " on repo " ++ repo
192197
x:_ -> return x
193198
when (isNothing builtHash) $
194-
logWarn $ "Information about the commit this version of stack was "
199+
prettyWarnS $
200+
"Information about the commit this version of stack was "
195201
<> "built from is not available due to how it was built. "
196202
<> "Will continue by assuming an upgrade is needed "
197203
<> "because we have no information to the contrary."
198204
if builtHash == Just latestCommit
199205
then do
200-
logInfo "Already up-to-date, no upgrade required"
206+
prettyInfoS "Already up-to-date, no upgrade required"
201207
return Nothing
202208
else do
203-
logInfo "Cloning stack"
209+
prettyInfoS "Cloning stack"
204210
-- NOTE: "--recursive" was added after v1.0.0 (and before the
205211
-- next release). This means that we can't use submodules in
206212
-- the stack repo until we're comfortable with "stack upgrade
@@ -221,7 +227,7 @@ sourceUpgrade gConfigMonoid mresolver builtHash (SourceOpts gitRepo) =
221227
let version = Data.List.maximum versions
222228
if version <= fromCabalVersion (mkVersion' Paths.version)
223229
then do
224-
logInfo "Already at latest version, no upgrade required"
230+
prettyInfoS "Already at latest version, no upgrade required"
225231
return Nothing
226232
else do
227233
let ident = PackageIdentifier $(mkPackageName "stack") version

0 commit comments

Comments
 (0)