diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-01-13 18:11:03 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-01-13 18:13:14 -0400 |
commit | de9ead9b92091e07795acf003dc05adb6912f15c (patch) | |
tree | 0ed928581ee2634134944e71cb87d6823d60733d /Remote | |
parent | e77d599e8f5167319b7624226dca02cfe0c65a77 (diff) |
implemented old Richih wishlist about remote/uuid info
* info: Can now display info about a given uuid.
* Added to remote/uuid info: Count of the number of keys present
on the remote, and their size. This is rather expensive to calculate,
so comes last and --fast will disable it.
* Git remote info now includes the date of the last sync with the remote.
Diffstat (limited to 'Remote')
-rw-r--r-- | Remote/GCrypt.hs | 2 | ||||
-rw-r--r-- | Remote/Git.hs | 2 | ||||
-rw-r--r-- | Remote/Helper/Git.hs | 19 |
3 files changed, 17 insertions, 6 deletions
diff --git a/Remote/GCrypt.hs b/Remote/GCrypt.hs index 2f2ddc9f3..6bf7f89f5 100644 --- a/Remote/GCrypt.hs +++ b/Remote/GCrypt.hs @@ -121,7 +121,7 @@ gen' r u c gc = do , availability = availabilityCalc r , remotetype = remote , mkUnavailable = return Nothing - , getInfo = return $ gitRepoInfo r + , getInfo = gitRepoInfo this , claimUrl = Nothing , checkUrl = Nothing } diff --git a/Remote/Git.hs b/Remote/Git.hs index 17b44fa6e..f015e295e 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -159,7 +159,7 @@ gen r u c gc , availability = availabilityCalc r , remotetype = remote , mkUnavailable = unavailable r u c gc - , getInfo = return $ gitRepoInfo r + , getInfo = gitRepoInfo new , claimUrl = Nothing , checkUrl = Nothing } diff --git a/Remote/Helper/Git.hs b/Remote/Helper/Git.hs index 156d7ac28..9ed27ac8b 100644 --- a/Remote/Helper/Git.hs +++ b/Remote/Helper/Git.hs @@ -10,6 +10,9 @@ module Remote.Helper.Git where import Common.Annex import qualified Git import Types.Availability +import qualified Types.Remote as Remote + +import Data.Time.Clock.POSIX repoCheap :: Git.Repo -> Bool repoCheap = not . Git.repoIsUrl @@ -31,7 +34,15 @@ guardUsable r fallback a | Git.repoIsLocalUnknown r = fallback | otherwise = a -gitRepoInfo :: Git.Repo -> [(String, String)] -gitRepoInfo r = - [ ("repository location", Git.repoLocation r) - ] +gitRepoInfo :: Remote -> Annex [(String, String)] +gitRepoInfo r = do + d <- fromRepo Git.localGitDir + mtimes <- liftIO $ mapM (modificationTime <$$> getFileStatus) + =<< dirContentsRecursive (d </> "refs" </> "remotes" </> Remote.name r) + let lastsynctime = case mtimes of + [] -> "never" + _ -> show $ posixSecondsToUTCTime $ realToFrac $ maximum mtimes + return + [ ("repository location", Git.repoLocation (Remote.repo r)) + , ("last synced", lastsynctime) + ] |