Skip to content

Commit 2365b26

Browse files
committed
Add script to generate pr's list
1 parent e53d9bc commit 2365b26

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

GenChangelogs.hs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env cabal
2+
{- cabal:
3+
build-depends: base, bytestring, process, text, github, time >= 1.9
4+
-}
5+
6+
{-# LANGUAGE OverloadedStrings #-}
7+
{-# LANGUAGE RecordWildCards #-}
8+
9+
import Control.Monad
10+
import qualified Data.ByteString.Char8 as BS
11+
import Data.List
12+
import Data.Maybe
13+
import qualified Data.Text as T
14+
import Data.Time.Format.ISO8601
15+
import Data.Time.LocalTime
16+
import GitHub
17+
import System.Environment
18+
import System.Process
19+
20+
main = do
21+
callCommand "git fetch --tags"
22+
tags <- filter (isPrefixOf "1.") . lines <$>
23+
readProcess "git" ["tag", "--list", "--sort=v:refname"] ""
24+
25+
lastDateStr <- last . lines <$> readProcess "git" ["show", "-s", "--format=%cI", "-1", last tags] ""
26+
lastDate <- zonedTimeToUTC <$> iso8601ParseM lastDateStr
27+
28+
args <- getArgs
29+
let githubReq = case args of
30+
[] -> github'
31+
token:_ -> github (OAuth $ BS.pack token)
32+
prs <- githubReq $ pullRequestsForR "haskell" "vscode-haskell" stateClosed FetchAll
33+
let prsAfterLastTag = either (error . show)
34+
(foldMap (\pr -> [pr | inRange pr]))
35+
prs
36+
inRange pr
37+
| Just mergedDate <- simplePullRequestMergedAt pr = mergedDate > lastDate
38+
| otherwise = False
39+
40+
forM_ prsAfterLastTag $ \SimplePullRequest{..} ->
41+
putStrLn $ T.unpack $ "- " <> simplePullRequestTitle <>
42+
"\n([#" <> T.pack (show $ unIssueNumber simplePullRequestNumber) <> "](" <> getUrl simplePullRequestHtmlUrl <> "))" <>
43+
" by @" <> untagName (simpleUserLogin simplePullRequestUser)

0 commit comments

Comments
 (0)