codex 0.1.0.4 → 0.1.0.5
raw patch · 5 files changed
+40/−7 lines, 5 filesdep ~bytestringdep ~codexPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: bytestring, codex
API changes (from Hackage documentation)
Files
- codex.cabal +3/−2
- codex/Main.hs +26/−1
- codex/Main/Config.hs +6/−0
- src/Codex.hs +3/−3
- src/Codex/Project.hs +2/−1
codex.cabal view
@@ -1,5 +1,5 @@ name: codex-version: 0.1.0.4+version: 0.1.0.5 synopsis: A ctags file generator for cabal project dependencies. description: This tool download and cache the source code of packages in your local hackage,@@ -55,6 +55,7 @@ build-depends: base , Cabal+ , bytestring , directory , either , filepath@@ -63,4 +64,4 @@ , monad-loops >= 0.4.2 && < 0.5 , transformers , yaml >= 0.8.8.3 && < 0.9- , codex == 0.1.0.4+ , codex == 0.1.0.5
codex/Main.hs view
@@ -31,8 +31,12 @@ tagsFile :: FilePath tagsFile = joinPath ["codex.tags"] +hashFile :: Codex -> FilePath+hashFile cx = hackagePath cx </> "codex.hash"+ cleanCache :: Codex -> IO () cleanCache cx = do+ -- TODO Delete hash file! xs <- listDirectory hp ys <- fmap (rights) $ traverse (safe . listDirectory) xs zs <- traverse (safe . removeFile) . fmap (</> "tags") $ concat ys@@ -43,6 +47,16 @@ xs <- getDirectoryContents fp return . fmap (fp </>) $ filter (not . startswith ".") xs +readCacheHash :: Codex -> IO (Maybe String)+readCacheHash cx = do+ fileExist <- doesFileExist $ hashFile cx+ if not fileExist then return Nothing else do+ content <- readFile $ hashFile cx+ return $ Just content++writeCacheHash :: Codex -> String -> IO ()+writeCacheHash cx = writeFile $ hashFile cx+ update :: Codex -> Bool -> IO () update cx force = do (project, dependencies, workspaceProjects) <- resolveCurrentProjectDependencies@@ -104,7 +118,18 @@ withConfig cx f = checkConfig cx >>= \state -> case state of TaggerNotFound -> fail $ "codex: tagger not found."- Ready -> f cx+ Ready -> do+ cacheHash' <- readCacheHash cx+ case cacheHash' of+ Just cacheHash ->+ when (cacheHash /= configHash) $ do+ putStrLn "codex: configuration has been updated, cleaning cache ..."+ cleanCache cx+ Nothing -> return ()+ res <- f cx+ writeCacheHash cx configHash+ return res where+ configHash = hashConfig cx fail msg = do putStrLn $ msg
codex/Main/Config.hs view
@@ -2,12 +2,15 @@ {-# LANGUAGE StandaloneDeriving #-} module Main.Config where +import Data.Hash.MD5 import Data.Yaml import GHC.Generics import System.Directory import System.FilePath +import qualified Data.ByteString.Char8 as BS+ import Codex import qualified Main.Config.Codex0 as C0@@ -32,6 +35,9 @@ _ -> TaggerNotFound where tagger = head $ words (tagsCmd cx)++hashConfig :: Codex -> String+hashConfig cfg = md5s . Str . BS.unpack $ encode cfg loadConfig :: IO Codex loadConfig = decodeConfig >>= maybe defaultConfig return where
src/Codex.hs view
@@ -123,7 +123,7 @@ TLIO.writeFile o $ TextL.unlines (concat [headers, ys]) tags i = packageTags cx i headers = if tagsFileHeader cx then fmap TextL.pack [headerFormat, headerSorted, headerHash] else []- headerFormat = "!_TAG_FILE_FORMAT 2"- headerSorted = concat ["!_TAG_FILE_SORTED ", if sorted then "1" else "0"]- headerHash = concat ["!_TAG_FILE_CODEX ", dependenciesHash dependencies]+ headerFormat = "!_TAG_FILE_FORMAT\t2"+ headerSorted = concat ["!_TAG_FILE_SORTED\t", if sorted then "1" else "0"]+ headerHash = concat ["!_TAG_FILE_CODEX\t", dependenciesHash dependencies] sorted = tagsFileSorted cx
src/Codex/Project.hs view
@@ -35,10 +35,11 @@ identifier = package . packageDescription allDependencies :: GenericPackageDescription -> [Dependency]-allDependencies pd = List.filter (not . isCurrent) $ concat [lds, eds, tds] where+allDependencies pd = List.filter (not . isCurrent) $ concat [lds, eds, tds, bds] where lds = condTreeConstraints =<< (maybeToList $ condLibrary pd) eds = (condTreeConstraints . snd) =<< condExecutables pd tds = (condTreeConstraints . snd) =<< condTestSuites pd+ bds = (condTreeConstraints . snd) =<< condBenchmarks pd isCurrent (Dependency n _) = n == (pkgName $ identifier pd) findPackageDescription :: FilePath -> IO (Maybe GenericPackageDescription)