import Remote.List
import Logs.Remote
import Logs.Trust
-import qualified Git.Config
import qualified Types.Remote as Remote
import Git.Types (RemoteName)
_ -> return ()
where
configured rc = fromMaybe False $
- Git.Config.isTrueFalse . fromProposedAccepted
+ trueFalseParser' . fromProposedAccepted
=<< M.lookup autoEnableField rc
canenable u = (/= DeadTrusted) <$> lookupTrust u
getenabledremotes = M.fromList
import Types.ProposedAccepted
import Types.RemoteConfig
import Types.GitConfig
-import qualified Git.Config
import qualified Data.Map as M
import qualified Data.Set as S
yesno _ = Nothing
trueFalseParser :: RemoteConfigField -> Bool -> FieldDesc -> RemoteConfigFieldParser
-trueFalseParser f v fd = genParser Git.Config.isTrueFalse f v fd
+trueFalseParser f v fd = genParser trueFalseParser' f v fd
(Just (ValueDesc "true or false"))
+-- Not using Git.Config.isTrueFalse because git supports
+-- a lot of other values for true and false in its configs,
+-- and this is not a git config and we want to avoid that mess.
+trueFalseParser' :: String -> Maybe Bool
+trueFalseParser' "true" = Just True
+trueFalseParser' "false" = Just False
+trueFalseParser' _ = Nothing
+
genParser
:: Typeable t
=> (String -> Maybe t)
* Fix a potential failure to parse git config.
* Support boolean git configs that are represented by the name of the
setting with no value, eg "core.bare" is the same as "core.bare = true".
+ * When parsing git configs, support all the documented ways to write
+ true and false, including "yes", "on", "1", etc.
-- Joey Hess <id@joeyh.name> Mon, 30 Mar 2020 15:58:34 -0400
isTrueFalse' :: ConfigValue -> Maybe Bool
isTrueFalse' (ConfigValue s)
+ | s' == "yes" = Just True
+ | s' == "on" = Just True
| s' == "true" = Just True
+ | s' == "1" = Just True
+
+ | s' == "no" = Just False
+ | s' == "off" = Just False
| s' == "false" = Just False
+ | s' == "0" = Just False
+ | s' == "" = Just False
+
| otherwise = Nothing
where
s' = S8.map toLower s