AssociatedFile newtype
To prevent any further mistakes like 301aff34c4
This commit was sponsored by Francois Marier on Patreon.
This commit is contained in:
parent
2cd7496210
commit
c8e1e3dada
43 changed files with 179 additions and 138 deletions
|
@ -136,8 +136,9 @@ instance Proto.Serializable Service where
|
|||
-- These mungings are ok, because an AssociatedFile is only ever displayed
|
||||
-- to the user and does not need to match a file on disk.
|
||||
instance Proto.Serializable AssociatedFile where
|
||||
serialize Nothing = ""
|
||||
serialize (Just af) = toInternalGitPath $ concatMap esc af
|
||||
serialize (AssociatedFile Nothing) = ""
|
||||
serialize (AssociatedFile (Just af)) =
|
||||
toInternalGitPath $ concatMap esc af
|
||||
where
|
||||
esc '%' = "%%"
|
||||
esc c
|
||||
|
@ -145,9 +146,9 @@ instance Proto.Serializable AssociatedFile where
|
|||
| otherwise = [c]
|
||||
|
||||
deserialize s = case fromInternalGitPath $ deesc [] s of
|
||||
[] -> Just Nothing
|
||||
[] -> Just (AssociatedFile Nothing)
|
||||
f
|
||||
| isRelative f -> Just (Just f)
|
||||
| isRelative f -> Just (AssociatedFile (Just f))
|
||||
| otherwise -> Nothing
|
||||
where
|
||||
deesc b [] = reverse b
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue