gitcache 0.2 → 0.3
raw patch · 2 files changed
+13/−5 lines, 2 filesdep +cryptonitedep −cryptohash
Dependencies added: cryptonite
Dependencies removed: cryptohash
Files
- gitcache.cabal +2/−2
- src/gitcache.hs +11/−3
gitcache.cabal view
@@ -1,5 +1,5 @@ Name: gitcache-Version: 0.2+Version: 0.3 Synopsis: Simple git utility to use and manage clone cache Description: Manage cache of git repository for faster cloning and offline working@@ -29,5 +29,5 @@ , filepath , directory , utf8-string- , cryptohash+ , cryptonite default-language: Haskell2010
src/gitcache.hs view
@@ -16,14 +16,19 @@ import System.FilePath import System.Process import System.Exit-import "cryptohash" Crypto.Hash+import Crypto.Hash import qualified Data.ByteString.UTF8 as UTF8 urlToHash :: String -> String urlToHash url = show (hash (UTF8.fromString url) :: Digest SHA1) urlToName :: String -> String-urlToName s = reverse $ fst $ break (== '/') $ reverse s+urlToName s+ | isPrefixOf "http://" s = httpUrl+ | isPrefixOf "https://" s = httpUrl+ | otherwise = sshUrl+ where httpUrl = reverse $ fst $ break (== '/') $ reverse s+ sshUrl = httpUrl rawSystemEC s l = do ec <- rawSystem s l@@ -80,7 +85,10 @@ putStrLn (repoDir ++ ": " ++ maybe "error: cannot determine 'url'" id url) listCacheRepos gitCacheDir =- filter (not . flip elem [".",".."]) <$> getDirectoryContents gitCacheDir+ (filter (not . flip elem [".",".."]) <$> getDirectoryContents gitCacheDir) >>= filterM isRepo+ where isRepo path = do+ dir <- doesDirectoryExist (gitCacheDir </> path)+ if not dir then return False else doesFileExist (gitCacheDir </> path </> "config") initialization = do gitCacheDir <- getGitCacheDir