-
Notifications
You must be signed in to change notification settings - Fork 0
/
GenChangelogs.hs
48 lines (43 loc) · 1.36 KB
/
GenChangelogs.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env cabal
{- cabal:
build-depends: base, process, text, github, time
-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.Text as T
import Data.Time.Format.ISO8601
import Data.Time.LocalTime
import GitHub
import System.Process
main :: IO ()
main = do
callCommand "git fetch --tags"
tags <-
filter (isPrefixOf "0.") . lines
<$> readProcess "git" ["tag", "--list", "--sort=v:refname"] ""
lastDateStr <- last . lines <$> readProcess "git" ["show", "-s", "--format=%cI", "-1", last tags] ""
lastDate <- zonedTimeToUTC <$> iso8601ParseM lastDateStr
prs <- github' $ pullRequestsForR "skykanin" "DraftGen" stateClosed FetchAll
let prsAfterLastTag =
either
(error . show)
(foldMap (\pr -> [pr | inRange pr]))
prs
inRange pr
| Just mergedDate <- simplePullRequestMergedAt pr = mergedDate > lastDate
| otherwise = False
forM_ prsAfterLastTag $ \SimplePullRequest {..} ->
putStrLn $
T.unpack $
"- "
<> simplePullRequestTitle
<> "\n([#"
<> T.pack (show $ unIssueNumber simplePullRequestNumber)
<> "]("
<> getUrl simplePullRequestHtmlUrl
<> "))"
<> " by @"
<> untagName (simpleUserLogin simplePullRequestUser)