refactoring
This commit is contained in:
parent
365c9767af
commit
c4977ec1ff
2 changed files with 8 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
{- Git configuration
|
{- Git configuration
|
||||||
-
|
-
|
||||||
- Copyright 2011-2017 Joey Hess <id@joeyh.name>
|
- Copyright 2011-2019 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -20,6 +20,8 @@ import Types.Availability
|
||||||
import Git.Types
|
import Git.Types
|
||||||
import qualified Types.Remote as Remote
|
import qualified Types.Remote as Remote
|
||||||
|
|
||||||
|
import qualified Data.Map as M
|
||||||
|
|
||||||
type UnqualifiedConfigKey = String
|
type UnqualifiedConfigKey = String
|
||||||
data ConfigKey = ConfigKey String
|
data ConfigKey = ConfigKey String
|
||||||
|
|
||||||
|
@ -59,6 +61,9 @@ instance RemoteNameable RemoteName where
|
||||||
instance RemoteNameable Remote where
|
instance RemoteNameable Remote where
|
||||||
getRemoteName = Remote.name
|
getRemoteName = Remote.name
|
||||||
|
|
||||||
|
instance RemoteNameable Remote.RemoteConfig where
|
||||||
|
getRemoteName c = fromMaybe "" (M.lookup "name" c)
|
||||||
|
|
||||||
{- A per-remote config setting in git config. -}
|
{- A per-remote config setting in git config. -}
|
||||||
remoteConfig :: RemoteNameable r => r -> UnqualifiedConfigKey -> ConfigKey
|
remoteConfig :: RemoteNameable r => r -> UnqualifiedConfigKey -> ConfigKey
|
||||||
remoteConfig r key = ConfigKey $
|
remoteConfig r key = ConfigKey $
|
||||||
|
|
|
@ -69,10 +69,8 @@ findSpecialRemotes s = do
|
||||||
gitConfigSpecialRemote :: UUID -> RemoteConfig -> [(String, String)] -> Annex ()
|
gitConfigSpecialRemote :: UUID -> RemoteConfig -> [(String, String)] -> Annex ()
|
||||||
gitConfigSpecialRemote u c cfgs = do
|
gitConfigSpecialRemote u c cfgs = do
|
||||||
forM_ cfgs $ \(k, v) ->
|
forM_ cfgs $ \(k, v) ->
|
||||||
setConfig (remoteConfig remotename k) v
|
setConfig (remoteConfig c k) v
|
||||||
setConfig (remoteConfig remotename "uuid") (fromUUID u)
|
setConfig (remoteConfig c "uuid") (fromUUID u)
|
||||||
where
|
|
||||||
remotename = fromJust (M.lookup "name" c)
|
|
||||||
|
|
||||||
-- RetrievalVerifiableKeysSecure unless overridden by git config.
|
-- RetrievalVerifiableKeysSecure unless overridden by git config.
|
||||||
--
|
--
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue