Commit a7efa1d4 authored by byorgey's avatar byorgey
Browse files

init: bug fix: ignore leading comments in files like .darcs/author

parent 0124d9bd
...@@ -322,12 +322,19 @@ gitConfigQuery which key = ...@@ -322,12 +322,19 @@ gitConfigQuery which key =
maybeFlag :: String -> Enviro -> Flag String maybeFlag :: String -> Enviro -> Flag String
maybeFlag k = maybe mempty Flag . lookup k maybeFlag k = maybe mempty Flag . lookup k
-- | Read the first non-comment, non-trivial line of a file, if it exists
maybeReadFile :: String -> IO (Maybe String) maybeReadFile :: String -> IO (Maybe String)
maybeReadFile f = do maybeReadFile f = do
exists <- doesFileExist f exists <- doesFileExist f
if exists if exists
then fmap Just $ readFile f then fmap getFirstLine $ readFile f
else return Nothing else return Nothing
where
getFirstLine content =
let nontrivialLines = dropWhile (\l -> (null l) || ("#" `isPrefixOf` l)) . lines $ content
in case nontrivialLines of
[] -> Nothing
(l:_) -> Just l
-- |Get list of categories used in Hackage. NOTE: Very slow, needs to be cached -- |Get list of categories used in Hackage. NOTE: Very slow, needs to be cached
knownCategories :: SourcePackageDb -> [String] knownCategories :: SourcePackageDb -> [String]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment