Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 774b2c8

Browse files
committed
Tidy up
1 parent 315e360 commit 774b2c8

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

GenChangelogs.hs

+15-4
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,31 @@ main = do
2121
callCommand "git fetch --tags"
2222
tags <- filter (isPrefixOf "0.") . lines <$>
2323
readProcess "git" ["tag", "--list", "--sort=v:refname"] ""
24-
let lastTag = last tags
25-
messages <- lines <$>
26-
readProcess "git" ["log", last tags <> "..HEAD", "--merges", "--reverse", "--pretty=format:\"%s\""] ""
24+
messages <- lines <$> readProcess "git" [ "log",
25+
, last tags <> "..HEAD"
26+
, "--merges"
27+
, "--revers",
28+
, "--pretty=format:\"%s\""
29+
] ""
2730

28-
let prNums = map (filter isDigit) $ map head $ filter (not . null) $ map (filter (isPrefixOf "#") . words) messages
31+
let -- try to get "1334" out of "merge PR #1334"
32+
prNums = map (filter isDigit) $
33+
map head $
34+
filter (not . null) $
35+
map (filter (isPrefixOf "#") . words) messages
2936
prUrls = map ("https://github.com/haskell/haskell-ide-engine/pull/" <>) prNums
3037

3138
(flip mapM_) prUrls $ \url -> do
3239
body <- getResponseBody <$> httpLBS (parseRequest_ url)
3340
let cursor = fromDocument (parseLBS body)
41+
3442
titles = (descendant >=> attributeIs "class" "js-issue-title" >=> child >=> content) cursor
3543
title = T.unpack $ T.strip $ head titles
44+
3645
checkAuthor :: Element -> Bool
3746
checkAuthor e = maybe False (T.isInfixOf "author") (M.lookup "class" (elementAttributes e))
3847
authors = (descendant >=> checkElement checkAuthor >=> child >=> content) cursor
3948
author = T.unpack $ T.strip $ authors !! 2 -- second author is the pr author
49+
50+
-- generate markdown
4051
putStrLn $ "- [" <> title <> "](" <> url <> ") (@" <> author <> ")"

0 commit comments

Comments
 (0)