From 6d5ced6d2490793680f2b4344d102769774f3a87 Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Sun, 31 Mar 2019 20:16:18 +0200 Subject: Fix replaceVersionDecl for Cabal HEAD It breaks when there's a `cabal-version:` delaration in the file. --- src/CabalHelper/Compiletime/Cabal.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/CabalHelper/Compiletime/Cabal.hs b/src/CabalHelper/Compiletime/Cabal.hs index d1c6c1d..0a11ba3 100644 --- a/src/CabalHelper/Compiletime/Cabal.hs +++ b/src/CabalHelper/Compiletime/Cabal.hs @@ -217,7 +217,9 @@ unpackCabalHEAD tmpdir = do -- | Replace the version declaration in a cabal file replaceVersionDecl :: (Version -> Maybe Version) -> String -> Maybe String replaceVersionDecl ver_fn cf = let - Just (before_ver,m) = find (\(_i,t) -> "version:" `isPrefixOf` t) $ splits cf + isVersionDecl ([],t) = "version:" `isPrefixOf` t + isVersionDecl (i,t) = "\n" `isSuffixOf` i && "version:" `isPrefixOf` t + Just (before_ver,m) = find isVersionDecl $ splits cf Just (ver_decl,after_ver) = find (\s -> case s of (_i,'\n':x:_) -> not $ isSpace x; _ -> False) $ filter (\(_i,t) -> "\n" `isPrefixOf` t) -- cgit v1.2.3