2dd38b6403
When I put in Haskell98 this spring, I was under the mistaken apprehension that ghc defaulted to that. But it actually its default is a third mode, which is closer to Haskell2010 but with some differences. The manual says "By default, GHC mainly aims to behave (mostly) like a Haskell 2010 compiler" Fixed two cases where the Haskell98 do indentation flexability let wrongly indented code build. That is one of the places where ghc does not behave like Haskell2010 by default. The other place that I think I was concerned about, is GHC manual section 19.1.1.3. Expressions and patterns. But that only seems to affect code using bottoms, so would only affect pure functions throwing an error, which I don't think git-annex does in many places as it's pretty horrid style. And it would only affect rare cases like shown in that section. If it did happen, it would mean that the error was not thrown before specifying Haskell98, and then was. Haskell2010 behaves the same as Haskell98. This commit was sponsored by Denis Dzyubenko on Patreon.
50 lines
1.3 KiB
Haskell
50 lines
1.3 KiB
Haskell
{- git-annex command
|
|
-
|
|
- Copyright 2011-2020 Joey Hess <id@joeyh.name>
|
|
-
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
-}
|
|
|
|
module Command.Upgrade where
|
|
|
|
import Command
|
|
import Upgrade
|
|
import Annex.Version
|
|
import Annex.Init
|
|
|
|
cmd :: Command
|
|
cmd = dontCheck
|
|
-- because an old version may not seem to exist
|
|
-- and also, this avoids automatic silent upgrades before
|
|
-- this command can start up.
|
|
repoExists $
|
|
-- avoid upgrading repo out from under daemon
|
|
noDaemonRunning $
|
|
command "upgrade" SectionMaintenance "upgrade repository"
|
|
paramNothing (seek <$$> optParser)
|
|
|
|
data UpgradeOptions = UpgradeOptions
|
|
{ autoOnly :: Bool
|
|
}
|
|
|
|
optParser :: CmdParamsDesc -> Parser UpgradeOptions
|
|
optParser _ = UpgradeOptions
|
|
<$> switch
|
|
( long "autoonly"
|
|
<> help "only do automatic upgrades"
|
|
)
|
|
|
|
seek :: UpgradeOptions -> CommandSeek
|
|
seek o = commandAction (start o)
|
|
|
|
start :: UpgradeOptions -> CommandStart
|
|
start (UpgradeOptions { autoOnly = True }) =
|
|
starting "upgrade" (ActionItemOther Nothing) (SeekInput []) $ do
|
|
getVersion >>= maybe noop checkUpgrade
|
|
next $ return True
|
|
start _ =
|
|
starting "upgrade" (ActionItemOther Nothing) (SeekInput []) $ do
|
|
whenM (isNothing <$> getVersion) $ do
|
|
initialize Nothing Nothing
|
|
r <- upgrade False latestVersion
|
|
next $ return r
|