Permalink
Browse files

Merge pull request #1018 from soenkehahn/master

fixed crash when printing latest versions with 'cabal install'
  • Loading branch information...
2 parents 0455ff5 + 31a59d1 commit 47f280e4ef254716eb386ad2727b0c4cfdf58da1 @byorgey byorgey committed Aug 28, 2012
Showing with 12 additions and 7 deletions.
  1. +12 −7 cabal-install/Distribution/Client/Install.hs
@@ -506,15 +506,20 @@ printPlan dryRun verbosity plan sourcePkgDb = case plan of
diff -> " changes: " ++ intercalate ", " (map change diff)
showLatest :: ConfiguredPackage -> String
- showLatest pkg = if pkgVersion /= latestVersion
- then (" (latest: " ++ display latestVersion ++ ")")
- else ""
+ showLatest pkg = case mLatestVersion of
+ Just latestVersion ->
+ if pkgVersion /= latestVersion
+ then (" (latest: " ++ display latestVersion ++ ")")
+ else ""
+ Nothing -> ""
where
pkgVersion = packageVersion pkg
- latestVersion =
- packageVersion . last
- . SourcePackageIndex.lookupPackageName (packageIndex sourcePkgDb)
- $ (packageName pkg)
+ mLatestVersion :: Maybe Version
+ mLatestVersion = case SourcePackageIndex.lookupPackageName
+ (packageIndex sourcePkgDb)
+ (packageName pkg) of
+ [] -> Nothing
+ x -> Just $ packageVersion $ last x
toFlagAssignment :: [Flag] -> FlagAssignment
toFlagAssignment = map (\ f -> (flagName f, flagDefault f))

0 comments on commit 47f280e

Please sign in to comment.