summaryrefslogtreecommitdiff
path: root/Remote/List.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Remote/List.hs')
-rw-r--r--Remote/List.hs37
1 files changed, 32 insertions, 5 deletions
diff --git a/Remote/List.hs b/Remote/List.hs
index 14a1771b4..3f3792744 100644
--- a/Remote/List.hs
+++ b/Remote/List.hs
@@ -2,7 +2,7 @@
{- git-annex remote list
-
- - Copyright 2011 Joey Hess <joey@kitenet.net>
+ - Copyright 2011,2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -18,6 +18,8 @@ import Types.Remote
import Annex.UUID
import Config
import Remote.Helper.Hooks
+import qualified Git
+import qualified Git.Config
import qualified Remote.Git
#ifdef WITH_S3
@@ -55,10 +57,35 @@ remoteList = do
return rs'
else return rs
where
- process m t = enumerate t >>= mapM (gen m t)
- gen m t r = do
- u <- getRepoUUID r
- addHooks =<< generate t r u (M.lookup u m)
+ process m t = enumerate t >>= mapM (remoteGen m t)
+
+{- Forces the remoteList to be re-generated, re-reading the git config. -}
+remoteListRefresh :: Annex [Remote]
+remoteListRefresh = do
+ newg <- inRepo Git.Config.reRead
+ Annex.changeState $ \s -> s
+ { Annex.remotes = []
+ , Annex.repo = newg
+ }
+ remoteList
+
+{- Generates a Remote. -}
+remoteGen :: (M.Map UUID RemoteConfig) -> RemoteType -> Git.Repo -> Annex Remote
+remoteGen m t r = do
+ u <- getRepoUUID r
+ addHooks =<< generate t r u (M.lookup u m)
+
+{- Updates a local git Remote, re-reading its git config. -}
+updateRemote :: Remote -> Annex Remote
+updateRemote remote = do
+ m <- readRemoteLog
+ remote' <- updaterepo $ repo remote
+ remoteGen m (remotetype remote) remote'
+ where
+ updaterepo r
+ | Git.repoIsLocal r || Git.repoIsLocalUnknown r =
+ Remote.Git.configRead r
+ | otherwise = return r
{- All remotes that are not ignored. -}
enabledRemoteList :: Annex [Remote]