automate remote.name.skipFetchAll

initremote, enableremote: Set remote.name.skipFetchAll when the remote
cannot be fetched from by git, so git fetch --all will not try to use it.
This commit is contained in:
Joey Hess 2020-02-19 13:58:26 -04:00
parent 69f2d1dd43
commit 79a0435b77
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 22 additions and 13 deletions

View file

@ -60,7 +60,7 @@ calcSyncRemotes = do
return $ \dstatus -> dstatus return $ \dstatus -> dstatus
{ syncRemotes = syncable { syncRemotes = syncable
, syncGitRemotes = filter Remote.gitSyncableRemote syncable , syncGitRemotes = filter (Remote.gitSyncableRemoteType . Remote.remotetype) syncable
, syncDataRemotes = dataremotes , syncDataRemotes = dataremotes
, exportRemotes = exportremotes , exportRemotes = exportremotes
, downloadRemotes = contentremotes , downloadRemotes = contentremotes

View file

@ -2,6 +2,9 @@ git-annex (7.20200220) UNRELEASED; urgency=medium
* Bugfix: export --tracking (a deprecated option) set * Bugfix: export --tracking (a deprecated option) set
annex-annex-tracking-branch, instead of annex-tracking-branch. annex-annex-tracking-branch, instead of annex-tracking-branch.
* initremote, enableremote: Set remote.name.skipFetchAll when
the remote cannot be fetched from by git, so git fetch --all
will not try to use it.
-- Joey Hess <id@joeyh.name> Wed, 19 Feb 2020 12:48:58 -0400 -- Joey Hess <id@joeyh.name> Wed, 19 Feb 2020 12:48:58 -0400

View file

@ -1,6 +1,6 @@
{- git-annex command {- git-annex command
- -
- Copyright 2013-2019 Joey Hess <id@joeyh.name> - Copyright 2013-2020 Joey Hess <id@joeyh.name>
- -
- Licensed under the GNU AGPL version 3 or higher. - Licensed under the GNU AGPL version 3 or higher.
-} -}
@ -25,6 +25,7 @@ import Config
import Config.DynamicConfig import Config.DynamicConfig
import Types.GitConfig import Types.GitConfig
import Types.ProposedAccepted import Types.ProposedAccepted
import Git.Config
import qualified Data.Map as M import qualified Data.Map as M
@ -86,10 +87,10 @@ startSpecialRemote name config (Just (u, c, mcu)) =
performSpecialRemote :: RemoteType -> UUID -> R.RemoteConfig -> R.RemoteConfig -> RemoteGitConfig -> Maybe (SpecialRemote.ConfigFrom UUID) -> CommandPerform performSpecialRemote :: RemoteType -> UUID -> R.RemoteConfig -> R.RemoteConfig -> RemoteGitConfig -> Maybe (SpecialRemote.ConfigFrom UUID) -> CommandPerform
performSpecialRemote t u oldc c gc mcu = do performSpecialRemote t u oldc c gc mcu = do
(c', u') <- R.setup t (R.Enable oldc) (Just u) Nothing c gc (c', u') <- R.setup t (R.Enable oldc) (Just u) Nothing c gc
next $ cleanupSpecialRemote u' c' mcu next $ cleanupSpecialRemote t u' c' mcu
cleanupSpecialRemote :: UUID -> R.RemoteConfig -> Maybe (SpecialRemote.ConfigFrom UUID) -> CommandCleanup cleanupSpecialRemote :: RemoteType -> UUID -> R.RemoteConfig -> Maybe (SpecialRemote.ConfigFrom UUID) -> CommandCleanup
cleanupSpecialRemote u c mcu = do cleanupSpecialRemote t u c mcu = do
case mcu of case mcu of
Nothing -> Nothing ->
Logs.Remote.configSet u c Logs.Remote.configSet u c
@ -101,6 +102,8 @@ cleanupSpecialRemote u c mcu = do
Just r -> do Just r -> do
repo <- R.getRepo r repo <- R.getRepo r
setRemoteIgnore repo False setRemoteIgnore repo False
unless (Remote.gitSyncableRemoteType t) $
setConfig (remoteConfig c "skipFetchAll") (boolConfig True)
return True return True
unknownNameError :: String -> Annex a unknownNameError :: String -> Annex a

View file

@ -23,6 +23,7 @@ import Logs.Remote
import Types.GitConfig import Types.GitConfig
import Types.ProposedAccepted import Types.ProposedAccepted
import Config import Config
import Git.Config
cmd :: Command cmd :: Command
cmd = command "initremote" SectionSetup cmd = command "initremote" SectionSetup
@ -87,7 +88,7 @@ perform t name c o = do
dummycfg <- liftIO dummyRemoteGitConfig dummycfg <- liftIO dummyRemoteGitConfig
let c' = M.delete uuidField c let c' = M.delete uuidField c
(c'', u) <- R.setup t R.Init (sameasu <|> uuidfromuser) Nothing c' dummycfg (c'', u) <- R.setup t R.Init (sameasu <|> uuidfromuser) Nothing c' dummycfg
next $ cleanup u name c'' o next $ cleanup t u name c'' o
where where
uuidfromuser = case fromProposedAccepted <$> M.lookup uuidField c of uuidfromuser = case fromProposedAccepted <$> M.lookup uuidField c of
Just s Just s
@ -99,8 +100,8 @@ perform t name c o = do
uuidField :: R.RemoteConfigField uuidField :: R.RemoteConfigField
uuidField = Accepted "uuid" uuidField = Accepted "uuid"
cleanup :: UUID -> String -> R.RemoteConfig -> InitRemoteOptions -> CommandCleanup cleanup :: RemoteType -> UUID -> String -> R.RemoteConfig -> InitRemoteOptions -> CommandCleanup
cleanup u name c o = do cleanup t u name c o = do
case sameas o of case sameas o of
Nothing -> do Nothing -> do
describeUUID u (toUUIDDesc name) describeUUID u (toUUIDDesc name)
@ -109,6 +110,8 @@ cleanup u name c o = do
cu <- liftIO genUUID cu <- liftIO genUUID
setConfig (remoteAnnexConfig c "config-uuid") (fromUUID cu) setConfig (remoteAnnexConfig c "config-uuid") (fromUUID cu)
Logs.Remote.configSet cu c Logs.Remote.configSet cu c
unless (Remote.gitSyncableRemoteType t) $
setConfig (remoteConfig c "skipFetchAll") (boolConfig True)
return True return True
describeOtherParamsFor :: RemoteConfig -> RemoteType -> CommandPerform describeOtherParamsFor :: RemoteConfig -> RemoteType -> CommandPerform

View file

@ -199,7 +199,7 @@ seek' o = do
let withbranch a = a =<< getCurrentBranch let withbranch a = a =<< getCurrentBranch
remotes <- syncRemotes (syncWith o) remotes <- syncRemotes (syncWith o)
let gitremotes = filter Remote.gitSyncableRemote remotes let gitremotes = filter (Remote.gitSyncableRemoteType . Remote.remotetype) remotes
dataremotes <- filter (\r -> Remote.uuid r /= NoUUID) dataremotes <- filter (\r -> Remote.uuid r /= NoUUID)
<$> filterM (not <$$> liftIO . getDynamicConfig . remoteAnnexIgnore . Remote.gitconfig) remotes <$> filterM (not <$$> liftIO . getDynamicConfig . remoteAnnexIgnore . Remote.gitconfig) remotes
let (exportremotes, keyvalueremotes) = partition (exportTree . Remote.config) dataremotes let (exportremotes, keyvalueremotes) = partition (exportTree . Remote.config) dataremotes
@ -300,7 +300,7 @@ syncRemotes' ps available =
listed = concat <$> mapM Remote.byNameOrGroup ps listed = concat <$> mapM Remote.byNameOrGroup ps
good r good r
| Remote.gitSyncableRemote r = | Remote.gitSyncableRemoteType (Remote.remotetype r) =
Remote.Git.repoAvail =<< Remote.getRepo r Remote.Git.repoAvail =<< Remote.getRepo r
| otherwise = return True | otherwise = return True

View file

@ -24,7 +24,7 @@ module Remote (
remoteTypes, remoteTypes,
remoteList, remoteList,
remoteList', remoteList',
gitSyncableRemote, gitSyncableRemoteType,
remoteMap, remoteMap,
remoteMap', remoteMap',
uuidDescriptions, uuidDescriptions,

View file

@ -128,8 +128,8 @@ updateRemote remote = do
| otherwise = return r | otherwise = return r
{- Checks if a remote is syncable using git. -} {- Checks if a remote is syncable using git. -}
gitSyncableRemote :: Remote -> Bool gitSyncableRemoteType :: RemoteType -> Bool
gitSyncableRemote r = remotetype r `elem` gitSyncableRemoteType t = t `elem`
[ Remote.Git.remote [ Remote.Git.remote
, Remote.GCrypt.remote , Remote.GCrypt.remote
, Remote.P2P.remote , Remote.P2P.remote