avoid crashing when there are remotes using unparseable urls
Including the non-standard URI form that git-remote-gcrypt uses for rsync. Eg, "ook://foo:bar" cannot be parsed because "bar" is not a valid port number. But git could have a remote with that, it would try to run git-remote-ook to handle it. So, git-annex has to allow for such things, rather than crashing. This commit was sponsored by Luke Shumaker on Patreon.
This commit is contained in:
parent
aafb7f6eb9
commit
2aa4fab62a
8 changed files with 48 additions and 24 deletions
|
@ -1,6 +1,6 @@
|
|||
{- git repository urls
|
||||
-
|
||||
- Copyright 2010, 2011 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2021 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -23,6 +23,7 @@ import Git
|
|||
{- Scheme of an URL repo. -}
|
||||
scheme :: Repo -> String
|
||||
scheme Repo { location = Url u } = uriScheme u
|
||||
scheme Repo { location = UnparseableUrl u } = unparseableUrl u
|
||||
scheme repo = notUrl repo
|
||||
|
||||
{- Work around a bug in the real uriRegName
|
||||
|
@ -65,13 +66,18 @@ authority = authpart assemble
|
|||
{- Applies a function to extract part of the uriAuthority of an URL repo. -}
|
||||
authpart :: (URIAuth -> a) -> Repo -> Maybe a
|
||||
authpart a Repo { location = Url u } = a <$> uriAuthority u
|
||||
authpart _ Repo { location = UnparseableUrl u } = unparseableUrl u
|
||||
authpart _ repo = notUrl repo
|
||||
|
||||
{- Path part of an URL repo. -}
|
||||
path :: Repo -> FilePath
|
||||
path Repo { location = Url u } = uriPath u
|
||||
path Repo { location = UnparseableUrl u } = unparseableUrl u
|
||||
path repo = notUrl repo
|
||||
|
||||
notUrl :: Repo -> a
|
||||
notUrl repo = error $
|
||||
"acting on local git repo " ++ repoDescribe repo ++ " not supported"
|
||||
|
||||
unparseableUrl :: String -> a
|
||||
unparseableUrl u = error $ "unable to parse repo url " ++ u
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue