summaryrefslogtreecommitdiff
path: root/GitRepo.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-13 14:01:17 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-13 14:01:17 -0400
commit794d44cf1daf073f05d1a27b2a02c47db37c443a (patch)
tree02d494d5b34ec9da4068588f0808dfcf1d2546ad /GitRepo.hs
parent1dbf36bf9a951b7a92770ea0b57bc79c8b465795 (diff)
add remoteName
Diffstat (limited to 'GitRepo.hs')
-rw-r--r--GitRepo.hs25
1 files changed, 16 insertions, 9 deletions
diff --git a/GitRepo.hs b/GitRepo.hs
index f0686ff20..489c9cf75 100644
--- a/GitRepo.hs
+++ b/GitRepo.hs
@@ -40,11 +40,14 @@ import Utility
data GitRepo =
LocalGitRepo {
top :: FilePath,
- config :: Map String String
+ config :: Map String String,
+ -- remoteName holds the name used for this repo in remotes
+ remoteName :: Maybe String
} | RemoteGitRepo {
url :: String,
top :: FilePath,
- config :: Map String String
+ config :: Map String String,
+ remoteName :: Maybe String
} deriving (Show, Read, Eq)
{- Local GitRepo constructor. Can optionally query the repo for its config. -}
@@ -52,7 +55,8 @@ gitRepoFromPath :: FilePath -> Bool -> IO GitRepo
gitRepoFromPath dir query = do
let r = LocalGitRepo {
top = dir,
- config = Map.empty
+ config = Map.empty,
+ remoteName = Nothing
}
if (query)
then gitConfigRead r
@@ -64,7 +68,8 @@ gitRepoFromUrl url query = do
return $ RemoteGitRepo {
url = url,
top = path url,
- config = Map.empty
+ config = Map.empty,
+ remoteName = Nothing
}
where path url = uriPath $ fromJust $ parseURI url
@@ -174,13 +179,15 @@ gitConfig repo key defaultValue =
gitConfigRemotes :: GitRepo -> IO [GitRepo]
gitConfigRemotes repo = mapM construct remotes
where
- remotes = elems $ filter $ config repo
+ remotes = toList $ filter $ config repo
filter = filterWithKey (\k _ -> isremote k)
isremote k = (startswith "remote." k) && (endswith ".url" k)
- construct r =
- if (isURI r)
- then gitRepoFromUrl r False
- else gitRepoFromPath r False
+ remotename k = (split "." k) !! 1
+ construct (k,v) = do
+ r <- if (isURI v)
+ then gitRepoFromUrl v False
+ else gitRepoFromPath v False
+ return r { remoteName = Just $ remotename k }
{- Finds the current git repository, which may be in a parent directory. -}
gitRepoFromCwd :: IO GitRepo