fix:setup: refactor, fix a case not returning installed version
This commit is contained in:
parent
6b5be96d27
commit
2288f5193d
@ -175,35 +175,23 @@ setupHledger = do
|
|||||||
_ -> p U $ "couldn't detect arch in --version output"
|
_ -> p U $ "couldn't detect arch in --version output"
|
||||||
|
|
||||||
pdesc "is up to date ?"
|
pdesc "is up to date ?"
|
||||||
elatestversionnumstr <- getLatestHledgerVersion
|
case drop 1 versionwords of
|
||||||
case elatestversionnumstr of
|
[] -> p U "couldn't parse --version output" >> return Nothing
|
||||||
Right latestversionnumstr ->
|
detailedversionstr:_ -> do
|
||||||
case drop 1 versionwords of
|
let
|
||||||
[] -> p U "couldn't parse --version output" >> return Nothing
|
versionnumstr = takeWhile (`elem` ("0123456789." :: String)) detailedversionstr
|
||||||
detailedversionstr:_ -> do
|
mversion = toVersion versionnumstr
|
||||||
let
|
case mversion of
|
||||||
versionnumstr = takeWhile (`elem` ("0123456789." :: String)) detailedversionstr
|
Nothing -> p U "couldn't parse --version's version number" >> return Nothing
|
||||||
mversion = toVersion versionnumstr
|
Just version -> do
|
||||||
mlatestversion = toVersion latestversionnumstr
|
elatestversionnumstr <- getLatestHledgerVersion
|
||||||
case (mversion, mlatestversion) of
|
case elatestversionnumstr of
|
||||||
(Nothing, _) -> p U "couldn't parse --version's version number" >> return Nothing
|
Left e -> p U ("couldn't read " <> latestHledgerVersionUrlStr <> " , " <> e)
|
||||||
(_, Nothing) -> p U "couldn't parse latest version number" >> return Nothing
|
Right latestversionnumstr ->
|
||||||
(Just version, Just latest) -> do
|
case toVersion latestversionnumstr of
|
||||||
p (if version >= latest then Y else N) (versionnumstr <> " installed, latest is " <> latestversionnumstr)
|
Nothing -> p U "couldn't parse latest version number"
|
||||||
return (Just (versionoutput, version))
|
Just latest -> p (if version >= latest then Y else N) (versionnumstr <> " installed, latest is " <> latestversionnumstr)
|
||||||
Left e -> do
|
return $ Just (versionoutput, version)
|
||||||
-- couldn't detect the latest version, but still return version info for the installed version
|
|
||||||
-- XXX duplication, refactor
|
|
||||||
case drop 1 versionwords of
|
|
||||||
[] -> p U "couldn't parse --version output" >> return Nothing
|
|
||||||
detailedversionstr:_ -> do
|
|
||||||
let
|
|
||||||
versionnumstr = takeWhile (`elem` ("0123456789." :: String)) detailedversionstr
|
|
||||||
mversion = toVersion versionnumstr
|
|
||||||
p U ("couldn't read " <> latestHledgerVersionUrlStr <> " : " <> e)
|
|
||||||
return $ case mversion of
|
|
||||||
Nothing -> Nothing
|
|
||||||
Just version -> Just (versionoutput, version)
|
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user