avoid partial functions in Git.Url
After the last commit, it was able to throw errors just due to an unparseable url. This avoids needing to worry about that, as long as the call site has already checked that it has a parseable url.
This commit is contained in:
parent
2aa4fab62a
commit
e7134ca1eb
3 changed files with 16 additions and 25 deletions
|
@ -121,16 +121,16 @@ localToUrl :: Repo -> Repo -> Repo
|
|||
localToUrl reference r
|
||||
| not $ repoIsUrl reference = error "internal error; reference repo not url"
|
||||
| repoIsUrl r = r
|
||||
| otherwise = case Url.authority reference of
|
||||
Nothing -> r
|
||||
Just auth ->
|
||||
| otherwise = case (Url.authority reference, Url.scheme reference) of
|
||||
(Just auth, Just s) ->
|
||||
let absurl = concat
|
||||
[ Url.scheme reference
|
||||
[ s
|
||||
, "//"
|
||||
, auth
|
||||
, fromRawFilePath (repoPath r)
|
||||
]
|
||||
in r { location = Url $ fromJust $ parseURI absurl }
|
||||
_ -> r
|
||||
|
||||
{- Calculates a list of a repo's configured remotes, by parsing its config. -}
|
||||
fromRemotes :: Repo -> IO [Repo]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue