move repoConfig out of Remotes
This commit is contained in:
parent
acde7a1736
commit
aad1372880
3 changed files with 21 additions and 21 deletions
15
Annex.hs
15
Annex.hs
|
@ -16,10 +16,12 @@ module Annex (
|
||||||
gitRepo,
|
gitRepo,
|
||||||
queue,
|
queue,
|
||||||
queueRun,
|
queueRun,
|
||||||
setConfig
|
setConfig,
|
||||||
|
repoConfig
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.State
|
import Control.Monad.State
|
||||||
|
import Data.Maybe
|
||||||
|
|
||||||
import qualified GitRepo as Git
|
import qualified GitRepo as Git
|
||||||
import qualified GitQueue
|
import qualified GitQueue
|
||||||
|
@ -115,3 +117,14 @@ setConfig k value = do
|
||||||
-- re-read git config and update the repo's state
|
-- re-read git config and update the repo's state
|
||||||
g' <- liftIO $ Git.configRead g
|
g' <- liftIO $ Git.configRead g
|
||||||
Annex.changeState $ \s -> s { Annex.repo = g' }
|
Annex.changeState $ \s -> s { Annex.repo = g' }
|
||||||
|
|
||||||
|
{- Looks up a per-remote config option in git config.
|
||||||
|
- Failing that, tries looking for a global config option. -}
|
||||||
|
repoConfig :: Git.Repo -> String -> String -> Annex String
|
||||||
|
repoConfig r key def = do
|
||||||
|
g <- Annex.gitRepo
|
||||||
|
let def' = Git.configGet g global def
|
||||||
|
return $ Git.configGet g local def'
|
||||||
|
where
|
||||||
|
local = "remote." ++ fromMaybe "" (Git.repoRemoteName r) ++ ".annex-" ++ key
|
||||||
|
global = "annex." ++ key
|
||||||
|
|
|
@ -204,7 +204,7 @@ tryScan r
|
||||||
configlist =
|
configlist =
|
||||||
Remotes.onRemote r (pipedconfig, Nothing) "configlist" []
|
Remotes.onRemote r (pipedconfig, Nothing) "configlist" []
|
||||||
manualconfiglist = do
|
manualconfiglist = do
|
||||||
sshoptions <- Remotes.repoConfig r "ssh-options" ""
|
sshoptions <- Annex.repoConfig r "ssh-options" ""
|
||||||
let sshcmd =
|
let sshcmd =
|
||||||
"cd " ++ shellEscape(Git.workTree r) ++ " && " ++
|
"cd " ++ shellEscape(Git.workTree r) ++ " && " ++
|
||||||
"git config --list"
|
"git config --list"
|
||||||
|
|
25
Remotes.hs
25
Remotes.hs
|
@ -15,8 +15,7 @@ module Remotes (
|
||||||
byName,
|
byName,
|
||||||
copyFromRemote,
|
copyFromRemote,
|
||||||
copyToRemote,
|
copyToRemote,
|
||||||
onRemote,
|
onRemote
|
||||||
repoConfig
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Exception.Extensible
|
import Control.Exception.Extensible
|
||||||
|
@ -26,7 +25,6 @@ import Data.String.Utils
|
||||||
import System.Cmd.Utils
|
import System.Cmd.Utils
|
||||||
import Data.List (intersect, sortBy)
|
import Data.List (intersect, sortBy)
|
||||||
import Control.Monad (when, unless, filterM)
|
import Control.Monad (when, unless, filterM)
|
||||||
import Data.Maybe
|
|
||||||
|
|
||||||
import Types
|
import Types
|
||||||
import qualified GitRepo as Git
|
import qualified GitRepo as Git
|
||||||
|
@ -182,7 +180,7 @@ reposByCost l = do
|
||||||
-}
|
-}
|
||||||
repoCost :: Git.Repo -> Annex Int
|
repoCost :: Git.Repo -> Annex Int
|
||||||
repoCost r = do
|
repoCost r = do
|
||||||
cost <- repoConfig r "cost" ""
|
cost <- Annex.repoConfig r "cost" ""
|
||||||
if not $ null cost
|
if not $ null cost
|
||||||
then return $ read cost
|
then return $ read cost
|
||||||
else if Git.repoIsUrl r
|
else if Git.repoIsUrl r
|
||||||
|
@ -194,7 +192,7 @@ repoCost r = do
|
||||||
- annex-ignore. -}
|
- annex-ignore. -}
|
||||||
repoNotIgnored :: Git.Repo -> Annex Bool
|
repoNotIgnored :: Git.Repo -> Annex Bool
|
||||||
repoNotIgnored r = do
|
repoNotIgnored r = do
|
||||||
ignored <- repoConfig r "ignore" "false"
|
ignored <- Annex.repoConfig r "ignore" "false"
|
||||||
to <- match Annex.toremote
|
to <- match Annex.toremote
|
||||||
from <- match Annex.fromremote
|
from <- match Annex.fromremote
|
||||||
if to || from
|
if to || from
|
||||||
|
@ -282,7 +280,7 @@ rsyncParams r sending key file = do
|
||||||
]
|
]
|
||||||
-- Convert the ssh command into rsync command line.
|
-- Convert the ssh command into rsync command line.
|
||||||
let eparam = rsyncShell (Param shellcmd:shellparams)
|
let eparam = rsyncShell (Param shellcmd:shellparams)
|
||||||
o <- repoConfig r "rsync-options" ""
|
o <- Annex.repoConfig r "rsync-options" ""
|
||||||
let base = options ++ map Param (words o) ++ eparam
|
let base = options ++ map Param (words o) ++ eparam
|
||||||
if sending
|
if sending
|
||||||
then return $ base ++ [dummy, File file]
|
then return $ base ++ [dummy, File file]
|
||||||
|
@ -316,9 +314,9 @@ git_annex_shell :: Git.Repo -> String -> [CommandParam] -> Annex (Maybe (FilePat
|
||||||
git_annex_shell r command params
|
git_annex_shell r command params
|
||||||
| not $ Git.repoIsUrl r = return $ Just (shellcmd, shellopts)
|
| not $ Git.repoIsUrl r = return $ Just (shellcmd, shellopts)
|
||||||
| Git.repoIsSsh r = do
|
| Git.repoIsSsh r = do
|
||||||
sshoptions <- repoConfig r "ssh-options" ""
|
sshoptions <- Annex.repoConfig r "ssh-options" ""
|
||||||
return $ Just ("ssh", map Param (words sshoptions) ++
|
return $ Just ("ssh", map Param (words sshoptions) ++
|
||||||
[Param (Git.urlAuthority r), Param sshcmd])
|
[Param (Git.urlHostUser r), Param sshcmd])
|
||||||
| otherwise = return Nothing
|
| otherwise = return Nothing
|
||||||
where
|
where
|
||||||
dir = Git.workTree r
|
dir = Git.workTree r
|
||||||
|
@ -326,14 +324,3 @@ git_annex_shell r command params
|
||||||
shellopts = (Param command):(File dir):params
|
shellopts = (Param command):(File dir):params
|
||||||
sshcmd = shellcmd ++ " " ++
|
sshcmd = shellcmd ++ " " ++
|
||||||
unwords (map shellEscape $ toCommand shellopts)
|
unwords (map shellEscape $ toCommand shellopts)
|
||||||
|
|
||||||
{- Looks up a per-remote config option in git config.
|
|
||||||
- Failing that, tries looking for a global config option. -}
|
|
||||||
repoConfig :: Git.Repo -> String -> String -> Annex String
|
|
||||||
repoConfig r key def = do
|
|
||||||
g <- Annex.gitRepo
|
|
||||||
let def' = Git.configGet g global def
|
|
||||||
return $ Git.configGet g local def'
|
|
||||||
where
|
|
||||||
local = "remote." ++ fromMaybe "" (Git.repoRemoteName r) ++ ".annex-" ++ key
|
|
||||||
global = "annex." ++ key
|
|
||||||
|
|
Loading…
Reference in a new issue