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.
This commit is contained in:
Joey Hess 2015-01-13 18:11:03 -04:00
parent c0722eaad1
commit 534c29deae
7 changed files with 81 additions and 16 deletions

View file

@ -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)
]