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:
Joey Hess 2021-01-18 15:07:23 -04:00
parent 2aa4fab62a
commit e7134ca1eb
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 16 additions and 25 deletions

View file

@ -255,14 +255,16 @@ discoverLFSEndpoint tro h
return Nothing
Just (Right hostuser) -> do
let port = Git.Url.port r
let p = fromMaybe (error "unknown path")
(Git.Url.path r)
-- Remove leading /~/ from path. That is added when
-- converting a scp-style repository location with
-- a relative path into an url, and is legal
-- according to git-clone(1), but github does not
-- support it.
let remotepath = if "/~/" `isPrefixOf` Git.Url.path r
then drop 3 (Git.Url.path r)
else Git.Url.path r
let remotepath = if "/~/" `isPrefixOf` p
then drop 3 p
else p
let ps = LFS.sshDiscoverEndpointCommand remotepath tro
-- Note that no shellEscape is done here, because
-- at least github's git-lfs implementation does