;tools: relnotes: more output, robustness
This commit is contained in:
parent
dda3855ba2
commit
483350c8cb
@ -18,12 +18,20 @@ and that changelogs and relnotes are non-empty with specific layout and heading
|
|||||||
In the end I wrote this in haskell because everything else was harder.
|
In the end I wrote this in haskell because everything else was harder.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# OPTIONS_GHC -Wno-x-partial #-}
|
||||||
|
|
||||||
|
import Control.Monad
|
||||||
import Data.Char
|
import Data.Char
|
||||||
import Data.List
|
import Data.List
|
||||||
|
import Data.List.Split
|
||||||
|
import System.Exit
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Process
|
import System.Process
|
||||||
import Text.Printf
|
import Text.Printf
|
||||||
|
|
||||||
|
strToVer = splitOn "."
|
||||||
|
verToStr = intercalate "."
|
||||||
|
|
||||||
main = do
|
main = do
|
||||||
-- gather latest release changes & info
|
-- gather latest release changes & info
|
||||||
(projectChangesHeading, projectChanges) <- changelogFirstSection <$> readFile "CHANGES.md"
|
(projectChangesHeading, projectChanges) <- changelogFirstSection <$> readFile "CHANGES.md"
|
||||||
@ -31,10 +39,23 @@ main = do
|
|||||||
(hledgerUiChangesHeading, hledgerUiChanges) <- changelogFirstSection <$> readFile "hledger-ui/CHANGES.md"
|
(hledgerUiChangesHeading, hledgerUiChanges) <- changelogFirstSection <$> readFile "hledger-ui/CHANGES.md"
|
||||||
(hledgerWebChangesHeading, hledgerWebChanges) <- changelogFirstSection <$> readFile "hledger-web/CHANGES.md"
|
(hledgerWebChangesHeading, hledgerWebChanges) <- changelogFirstSection <$> readFile "hledger-web/CHANGES.md"
|
||||||
reltags <- lines <$> readProcess "git" ["tag", "--sort=-creatordate", "-l", "[0-9]*"] ""
|
reltags <- lines <$> readProcess "git" ["tag", "--sort=-creatordate", "-l", "[0-9]*"] ""
|
||||||
|
printf $ "previous release tags: " <> unwords (take 5 reltags) <> " ...\n"
|
||||||
let
|
let
|
||||||
[_, ver, date] = words projectChangesHeading
|
[_, ver, date] = words projectChangesHeading
|
||||||
prevver:_ = drop 1 $ dropWhile (/=ver) reltags
|
verexists = ver `elem` reltags
|
||||||
relauthors <- map (unwords . drop 1 . words) . lines <$> readProcess "git" ["shortlog", "-sn", prevver<>".."<>ver] ""
|
printf $ "project CHANGES.md's top heading: " <> projectChangesHeading
|
||||||
|
printf $ "inferred latest release version and date: " <> intercalate ", " [ver, date] <> "\n"
|
||||||
|
printf $ "a tag for this release " <> (if verexists then "exists" else "does not yet exist") <> "\n"
|
||||||
|
let prevvers =
|
||||||
|
map verToStr $ dropWhile (>=strToVer ver) $ map strToVer $ reltags
|
||||||
|
printf $ "releases before this one: " <> unwords (take 5 prevvers) <> " ...\n"
|
||||||
|
when (null prevvers) $ do
|
||||||
|
printf $ "error: no previous releases found. This expects to run before new release headings are added to changelogs\n"
|
||||||
|
exitFailure
|
||||||
|
let prevver = head prevvers
|
||||||
|
printf $ "previous release: " <> prevver <> "\n"
|
||||||
|
relauthors <- map (unwords . drop 1 . words) . lines <$> readProcess "git" ["shortlog", "-sn", prevver<>".."<>if verexists then ver else ""] ""
|
||||||
|
printf $ "this release's authors: " <> intercalate ", " relauthors <> "\n"
|
||||||
|
|
||||||
-- convert to release notes format
|
-- convert to release notes format
|
||||||
let
|
let
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user