This commit is contained in:
Joey Hess 2010-10-28 12:15:21 -04:00
parent 1118b4a646
commit 9c7b3dce9e
2 changed files with 13 additions and 9 deletions

View file

@ -24,6 +24,7 @@ module GitRepo (
configGet, configGet,
configMap, configMap,
configRead, configRead,
configTrue,
run, run,
pipeRead, pipeRead,
attributes, attributes,
@ -47,6 +48,7 @@ import Data.String.Utils
import Data.Map as Map hiding (map, split) import Data.Map as Map hiding (map, split)
import Network.URI import Network.URI
import Maybe import Maybe
import Char
import Utility import Utility
@ -127,13 +129,11 @@ assertssh repo action =
then action then action
else error $ "unsupported url " ++ (show $ url repo) else error $ "unsupported url " ++ (show $ url repo)
bare :: Repo -> Bool bare :: Repo -> Bool
bare repo = bare repo = case Map.lookup "core.bare" $ config repo of
if (member b (config repo)) Just v -> configTrue v
then ("true" == fromJust (Map.lookup b (config repo))) Nothing -> error $ "it is not known if git repo " ++
else error $ "it is not known if git repo " ++ (repoDescribe repo) ++ (repoDescribe repo) ++
" is a bare repository; config not read" " is a bare repository; config not read"
where
b = "core.bare"
{- Path to a repository's gitattributes file. -} {- Path to a repository's gitattributes file. -}
attributes :: Repo -> String attributes :: Repo -> String
@ -173,7 +173,7 @@ relative repo file = assertLocal repo $ drop (length absrepo) absfile
{- Hostname of an URL repo. (May include a username and/or port too.) -} {- Hostname of an URL repo. (May include a username and/or port too.) -}
urlHost :: Repo -> String urlHost :: Repo -> String
urlHost repo = assertUrl repo $ urlHost repo = assertUrl repo $
(uriUserInfo a) ++ (uriRegName a) ++ (uriPort a) uriUserInfo a ++ uriRegName a ++ uriPort a
where where
a = fromJust $ uriAuthority $ url repo a = fromJust $ uriAuthority $ url repo
@ -235,6 +235,10 @@ configRead repo =
let r = repo { config = configParse val } let r = repo { config = configParse val }
return r { remotes = configRemotes r } return r { remotes = configRemotes r }
{- Checks if a string fron git config is a true value. -}
configTrue :: String -> Bool
configTrue s = map toLower s == "true"
{- Calculates a list of a repo's configured remotes, by parsing its config. -} {- Calculates a list of a repo's configured remotes, by parsing its config. -}
configRemotes :: Repo -> [Repo] configRemotes :: Repo -> [Repo]
configRemotes repo = map construct remotes configRemotes repo = map construct remotes

View file

@ -139,10 +139,10 @@ repoNotIgnored r = do
let name = if (not $ null fromName) then fromName else toName let name = if (not $ null fromName) then fromName else toName
if (not $ null name) if (not $ null name)
then return $ match name then return $ match name
else return $ notignored g else return $ not $ ignored g
where where
match name = name == Git.repoRemoteName r match name = name == Git.repoRemoteName r
notignored g = "true" /= config g ignored g = Git.configTrue $ config g
config g = Git.configGet g configkey "" config g = Git.configGet g configkey ""
configkey = "remote." ++ (Git.repoRemoteName r) ++ ".annex-ignore" configkey = "remote." ++ (Git.repoRemoteName r) ++ ".annex-ignore"