diff options
author | Joey Hess <joey@kitenet.net> | 2013-11-04 14:14:44 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-11-04 14:14:44 -0400 |
commit | 2e808304f546536277adf7611e19a0c4f7108dfe (patch) | |
tree | 9b23102ee03bc9ad84d72b265607b5ce86fd2b0c /Git | |
parent | bc71810c8e270d938c73fbe2b3a53808803fa417 (diff) |
map: Work when there are gcrypt remotes.
Diffstat (limited to 'Git')
-rw-r--r-- | Git/Construct.hs | 18 | ||||
-rw-r--r-- | Git/Url.hs | 23 |
2 files changed, 22 insertions, 19 deletions
diff --git a/Git/Construct.hs b/Git/Construct.hs index 6514b80bc..cd998591e 100644 --- a/Git/Construct.hs +++ b/Git/Construct.hs @@ -104,14 +104,16 @@ localToUrl :: Repo -> Repo -> Repo localToUrl reference r | not $ repoIsUrl reference = error "internal error; reference repo not url" | repoIsUrl r = r - | otherwise = r { location = Url $ fromJust $ parseURI absurl } - where - absurl = concat - [ Url.scheme reference - , "//" - , Url.authority reference - , repoPath r - ] + | otherwise = case Url.authority reference of + Nothing -> r + Just auth -> + let absurl = concat + [ Url.scheme reference + , "//" + , auth + , repoPath r + ] + in r { location = Url $ fromJust $ parseURI absurl } {- Calculates a list of a repo's configured remotes, by parsing its config. -} fromRemotes :: Repo -> IO [Repo] diff --git a/Git/Url.hs b/Git/Url.hs index 7befc4669..d383a6aca 100644 --- a/Git/Url.hs +++ b/Git/Url.hs @@ -37,32 +37,33 @@ uriRegName' a = fixup $ uriRegName a fixup x = x {- Hostname of an URL repo. -} -host :: Repo -> String +host :: Repo -> Maybe String host = authpart uriRegName' {- Port of an URL repo, if it has a nonstandard one. -} port :: Repo -> Maybe Integer port r = case authpart uriPort r of - ":" -> Nothing - (':':p) -> readish p - _ -> Nothing + Nothing -> Nothing + Just ":" -> Nothing + Just (':':p) -> readish p + Just _ -> Nothing {- Hostname of an URL repo, including any username (ie, "user@host") -} -hostuser :: Repo -> String -hostuser r = authpart uriUserInfo r ++ authpart uriRegName' r +hostuser :: Repo -> Maybe String +hostuser r = (++) + <$> authpart uriUserInfo r + <*> authpart uriRegName' r {- The full authority portion an URL repo. (ie, "user@host:port") -} -authority :: Repo -> String +authority :: Repo -> Maybe String authority = authpart assemble where assemble a = uriUserInfo a ++ uriRegName' a ++ uriPort a {- Applies a function to extract part of the uriAuthority of an URL repo. -} -authpart :: (URIAuth -> a) -> Repo -> a -authpart a Repo { location = Url u } = a auth - where - auth = fromMaybe (error $ "bad url " ++ show u) (uriAuthority u) +authpart :: (URIAuth -> a) -> Repo -> Maybe a +authpart a Repo { location = Url u } = a <$> uriAuthority u authpart _ repo = notUrl repo notUrl :: Repo -> a |