summaryrefslogtreecommitdiff
path: root/GitRepo.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-28 12:15:21 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-28 12:15:21 -0400
commit9c7b3dce9e8f964ed60dd45bca580a46ff8a5ed5 (patch)
tree6c03ee53e3b0936839bb36c0548c2a700d582847 /GitRepo.hs
parent1118b4a6466f3453f5c517ff8eadbfbd1a4895f1 (diff)
tweaks
Diffstat (limited to 'GitRepo.hs')
-rw-r--r--GitRepo.hs18
1 files changed, 11 insertions, 7 deletions
diff --git a/GitRepo.hs b/GitRepo.hs
index 229b76847..0e87c9526 100644
--- a/GitRepo.hs
+++ b/GitRepo.hs
@@ -24,6 +24,7 @@ module GitRepo (
configGet,
configMap,
configRead,
+ configTrue,
run,
pipeRead,
attributes,
@@ -47,6 +48,7 @@ import Data.String.Utils
import Data.Map as Map hiding (map, split)
import Network.URI
import Maybe
+import Char
import Utility
@@ -127,13 +129,11 @@ assertssh repo action =
then action
else error $ "unsupported url " ++ (show $ url repo)
bare :: Repo -> Bool
-bare repo =
- if (member b (config repo))
- then ("true" == fromJust (Map.lookup b (config repo)))
- else error $ "it is not known if git repo " ++ (repoDescribe repo) ++
+bare repo = case Map.lookup "core.bare" $ config repo of
+ Just v -> configTrue v
+ Nothing -> error $ "it is not known if git repo " ++
+ (repoDescribe repo) ++
" is a bare repository; config not read"
- where
- b = "core.bare"
{- Path to a repository's gitattributes file. -}
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.) -}
urlHost :: Repo -> String
urlHost repo = assertUrl repo $
- (uriUserInfo a) ++ (uriRegName a) ++ (uriPort a)
+ uriUserInfo a ++ uriRegName a ++ uriPort a
where
a = fromJust $ uriAuthority $ url repo
@@ -235,6 +235,10 @@ configRead repo =
let r = repo { config = configParse val }
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. -}
configRemotes :: Repo -> [Repo]
configRemotes repo = map construct remotes