2013-09-07 22:38:00 +00:00
|
|
|
{- Utilities for git remotes.
|
|
|
|
-
|
2014-01-13 18:41:10 +00:00
|
|
|
- Copyright 2011-2014 Joey Hess <joey@kitenet.net>
|
2013-09-07 22:38:00 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Remote.Helper.Git where
|
|
|
|
|
|
|
|
import Common.Annex
|
|
|
|
import qualified Git
|
2014-01-13 18:41:10 +00:00
|
|
|
import Types.Availability
|
2013-09-07 22:38:00 +00:00
|
|
|
|
|
|
|
repoCheap :: Git.Repo -> Bool
|
|
|
|
repoCheap = not . Git.repoIsUrl
|
|
|
|
|
|
|
|
localpathCalc :: Git.Repo -> Maybe FilePath
|
2014-01-13 18:41:10 +00:00
|
|
|
localpathCalc r
|
|
|
|
| availabilityCalc r == GloballyAvailable = Nothing
|
|
|
|
| otherwise = Just $ Git.repoPath r
|
2013-09-07 22:38:00 +00:00
|
|
|
|
2014-01-13 18:41:10 +00:00
|
|
|
availabilityCalc :: Git.Repo -> Availability
|
|
|
|
availabilityCalc r
|
|
|
|
| (Git.repoIsLocal r || Git.repoIsLocalUnknown r) = LocallyAvailable
|
|
|
|
| otherwise = GloballyAvailable
|
2013-09-07 22:38:00 +00:00
|
|
|
|
|
|
|
{- Avoids performing an action on a local repository that's not usable.
|
|
|
|
- Does not check that the repository is still available on disk. -}
|
2014-08-08 23:18:08 +00:00
|
|
|
guardUsable :: Git.Repo -> Annex a -> Annex a -> Annex a
|
|
|
|
guardUsable r fallback a
|
|
|
|
| Git.repoIsLocalUnknown r = fallback
|
2013-09-07 22:38:00 +00:00
|
|
|
| otherwise = a
|
2014-10-21 18:36:09 +00:00
|
|
|
|
|
|
|
gitRepoInfo :: Git.Repo -> [(String, String)]
|
|
|
|
gitRepoInfo r =
|
|
|
|
[ ("repository location", Git.repoLocation r)
|
|
|
|
]
|