mirror of
https://github.com/github/semantic.git
synced 2025-01-08 08:30:27 +03:00
Union the inner maps
This commit is contained in:
parent
b290e49000
commit
7c394ff6dd
@ -19,7 +19,7 @@ data DiffArguments = DiffArguments { format :: Format, output :: Maybe FilePath,
|
||||
data Format = Split | Patch | JSON | Summary
|
||||
deriving (Show)
|
||||
|
||||
data Output = SplitOutput Text | PatchOutput Text | JSONOutput (Map Text Value) | SummaryOutput (Map Text [Map Text [Text]])
|
||||
data Output = SplitOutput Text | PatchOutput Text | JSONOutput (Map Text Value) | SummaryOutput (Map Text (Map Text [Text]))
|
||||
deriving (Show)
|
||||
|
||||
-- Returns a key representing the filename. If the filenames are different,
|
||||
@ -46,8 +46,8 @@ concatOutputs list | isJSON list = toS . encodingToLazyByteString . toEncoding $
|
||||
concatJSON _ = mempty
|
||||
concatOutputs list | isSummary list = toS . encodingToLazyByteString . toEncoding $ concatSummaries list
|
||||
where
|
||||
concatSummaries :: [Output] -> Map Text [Map Text [Text]]
|
||||
concatSummaries (SummaryOutput hash : rest) = Map.unionWith (<>) hash (concatSummaries rest)
|
||||
concatSummaries :: [Output] -> Map Text (Map Text [Text])
|
||||
concatSummaries (SummaryOutput hash : rest) = Map.unionWith (Map.unionWith (<>)) hash (concatSummaries rest)
|
||||
concatSummaries _ = mempty
|
||||
concatOutputs list | isText list = T.intercalate "\n" (toText <$> list)
|
||||
concatOutputs _ = mempty
|
||||
|
@ -16,8 +16,8 @@ summary blobs diff = SummaryOutput $ Map.fromList [
|
||||
("errors", errors)
|
||||
]
|
||||
where
|
||||
changes = if null changes' then [] else [ Map.singleton summaryKey changes' ]
|
||||
errors = if null errors' then [] else [ Map.singleton summaryKey errors' ]
|
||||
changes = if null changes' then mempty else Map.singleton summaryKey changes'
|
||||
errors = if null errors' then mempty else Map.singleton summaryKey errors'
|
||||
(errors', changes') = partitionEithers summaries
|
||||
summaryKey = toSummaryKey (path <$> blobs)
|
||||
summaries = diffSummaries blobs diff
|
||||
|
Loading…
Reference in New Issue
Block a user