renderCommits repo commits =
    header <> foldr renderCommit "\n" commits <> footer
    where
        renderCommit v =
            mappend (foldMap rc $ (,) <$> v ^? commit . author . date . _String
                                      <*> v ^? commit . message . _String)
        rc (d, m) = F.build "[{}] {}\n" (d, firstLine m)
        firstLine = fromMaybe T.empty . listToMaybe . T.lines

        sumOn prism = maybe mempty Sum . preview prism
        fileCount   = key "files" . _Array . to V.length
        lineCount   = key "stats" . key "total" . _Number
        (Sum files, Sum lines) =
            foldMap (sumOn fileCount &&& sumOn lineCount) commits
        padS = F.left 5 ' ' . F.Shown

        header = "## Commits\n\n"
        footer = F.build "{} commits.\n{} files.\n{} lines.\n\n"
                         (padS $ length commits, padS files, padS $ round lines)
renderCommits repo commits =
    header <> foldr renderCommit "\n" commits <> footer
    where
        renderCommit v =
            mappend (foldMap rc $ (,) <$> v ^? commit . author . date . _String
                                      <*> v ^? commit . message . _String)
        rc (d, m) = F.build "[{}] {}\n" (d, firstLine m)
        firstLine = fromMaybe T.empty . listToMaybe . T.lines

        sumOn prism = maybe mempty Sum . preview prism
        fileCount   = key "files" . _Array . to V.length
        lineCount   = key "stats" . key "total" . _Number
        (Sum files, Sum lines) =
            foldMap (sumOn fileCount &&& sumOn lineCount) commits
        padS = F.left 5 ' ' . F.Shown

        header = "## Commits\n\n"
        footer = F.build "{} commits.\n{} files.\n{} lines.\n\n"
                         (padS $ length commits, padS files, padS $ round lines)
renderCommits repo commits =
    header <> foldr renderCommit "\n" commits <> footer
    where
        renderCommit v =
            mappend (foldMap rc $ (,) <$> v ^? commit . author . date . _String
                                      <*> v ^? commit . message . _String)
        rc (d, m) = F.build "[{}] {}\n" (d, firstLine m)
        firstLine = fromMaybe T.empty . listToMaybe . T.lines

        sumOn prism = maybe mempty Sum . preview prism
        fileCount   = key "files" . _Array . to V.length
        lineCount   = key "stats" . key "total" . _Number
        (Sum files, Sum lines) =
            foldMap (sumOn fileCount &&& sumOn lineCount) commits
        padS = F.left 5 ' ' . F.Shown

        header = "## Commits\n\n"
        footer = F.build "{} commits.\n{} files.\n{} lines.\n\n"
                         (padS $ length commits, padS files, padS $ round lines)