From da0a1360d7b57d034620338996552752ab873045 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 17 Aug 2017 12:26:14 -0400 Subject: add annex-ignore-command and annex-sync-command configs Added remote configuration settings annex-ignore-command and annex-sync-command, which are dynamic equivilants of the annex-ignore and annex-sync configurations. For this I needed a new DynamicConfig infrastructure. Its implementation should be as fast as before when there is no dynamic config, and it caches so shell commands are only run once. Note that annex-ignore-command exits nonzero when the remote should be ignored. While that may seem backwards, it allows using the same command for it as for annex-sync-command when you want to disable both. This commit was sponsored by Trenton Cronholm on Patreon. --- Remote.hs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'Remote.hs') diff --git a/Remote.hs b/Remote.hs index 8c774915a..877c9f37d 100644 --- a/Remote.hs +++ b/Remote.hs @@ -70,6 +70,7 @@ import Logs.Location hiding (logStatus) import Logs.Web import Remote.List import Config +import Config.DynamicConfig import Git.Types (RemoteName) import qualified Git @@ -120,12 +121,13 @@ byNameWithUUID = checkuuid <=< byName where checkuuid Nothing = return Nothing checkuuid (Just r) - | uuid r == NoUUID = giveup $ - if remoteAnnexIgnore (gitconfig r) - then noRemoteUUIDMsg r ++ + | uuid r == NoUUID = + ifM (liftIO $ getDynamicConfig $ remoteAnnexIgnore (gitconfig r)) + ( giveup $ noRemoteUUIDMsg r ++ " (" ++ show (remoteConfig (repo r) "ignore") ++ " is set)" - else noRemoteUUIDMsg r + , giveup $ noRemoteUUIDMsg r + ) | otherwise = return $ Just r byName' :: RemoteName -> Annex (Either String Remote) @@ -292,8 +294,8 @@ remoteLocations locations trusted = do let validtrustedlocations = nub locations `intersect` trusted -- remotes that match uuids that have the key - allremotes <- filter (not . remoteAnnexIgnore . gitconfig) - <$> remoteList + allremotes <- remoteList + >>= filterM (not <$$> liftIO . getDynamicConfig . remoteAnnexIgnore . gitconfig) let validremotes = remotesWithUUID allremotes locations return (sortBy (comparing cost) validremotes, validtrustedlocations) @@ -313,7 +315,8 @@ showLocations separateuntrusted key exclude nolocmsg = do let msg = message ppuuidswanted ppuuidsskipped unless (null msg) $ showLongNote msg - ignored <- filter (remoteAnnexIgnore . gitconfig) <$> remoteList + ignored <- remoteList + >>= filterM (liftIO . getDynamicConfig . remoteAnnexIgnore . gitconfig) unless (null ignored) $ showLongNote $ "(Note that these git remotes have annex-ignore set: " ++ unwords (map name ignored) ++ ")" where -- cgit v1.2.3