;shake: use --dry-run instead of changelogs-dry
This commit is contained in:
parent
00e12c626c
commit
731cda3f65
51
Shake.hs
51
Shake.hs
@ -62,27 +62,25 @@ usage =
|
|||||||
let scriptname = "Shake" in replaceRe [re|/Shake|] ('/':scriptname) $
|
let scriptname = "Shake" in replaceRe [re|/Shake|] ('/':scriptname) $
|
||||||
unlines
|
unlines
|
||||||
---------------------------------------79--------------------------------------
|
---------------------------------------79--------------------------------------
|
||||||
["hledger developer scripts that didn't fit in Makefile. See also: make help"
|
["hledger developer scripts. See also: make help"
|
||||||
,"Usage:"
|
,"Usage:"
|
||||||
,"./Shake.hs [CMD [ARGS]] run CMD, compiling this script first if needed"
|
,"./Shake.hs [CMD [ARGS]] run CMD, compiling this script first if needed"
|
||||||
,"./Shake [CMD [ARGS]] run CMD, using the compiled version of this script"
|
,"./Shake [CMD [ARGS]] run CMD, using the compiled version of this script"
|
||||||
,"./Shake [help] show this help"
|
,"./Shake [help] show this help"
|
||||||
,"./Shake commandtxts build plain text docs for hledger CLI command help"
|
,"./Shake setversion [VER] [PKGS]"
|
||||||
,"./Shake manuals build txt/man/info/web manuals for all packages"
|
," update version strings from */.version (or VER)"
|
||||||
,"./Shake webmanuals build web manuals (in site/) for all packages"
|
,"./Shake commandtxts update hledger CLI commands' usage texts"
|
||||||
-- TODO: commit, show commit
|
,"./Shake manuals update txt/man/info/web manuals for all packages"
|
||||||
,"./Shake setversion [VER] [PKGS] set version strings from */.version (or VER)"
|
,"./Shake webmanuals update just the web manuals"
|
||||||
-- TODO: commit, show commit
|
,"./Shake changelogs [--dry-run]"
|
||||||
,"./Shake changelogs[-dry] add new commits, headings to */CHANGES.md"
|
," add new commits & headings to */CHANGES.md"
|
||||||
-- ,"./Shake [PKG/]CHANGES.md[-dry] update (or preview) one changelog"
|
,"./Shake cabalfiles update */*.cabal from */package.yaml"
|
||||||
,"./Shake cabalfiles update .cabal files from */package.yaml"
|
|
||||||
,"./Shake build [PKGS] build hledger packages and their embedded docs"
|
,"./Shake build [PKGS] build hledger packages and their embedded docs"
|
||||||
,"./Shake clean clean generated help texts, manuals"
|
,"./Shake clean remove generated texts, manuals"
|
||||||
,"./Shake Clean also clean object files, Shake's cache"
|
,"./Shake Clean also remove object files, Shake's cache"
|
||||||
,"./Shake FILE build any individual file"
|
,"./Shake FILE build any individual file"
|
||||||
,"./Shake --help list Shake options (--color, --rebuild, ...)"
|
,"./Shake --help list Shake's options (--color, --rebuild, etc.)"
|
||||||
,""
|
,"Keep Shake option arguments adjacent to their flag."
|
||||||
,"Option arguments should be adjacent to their flag."
|
|
||||||
]
|
]
|
||||||
|
|
||||||
-- groff = "groff -c" ++ " -Wall" -- see "groff" below
|
-- groff = "groff -c" ++ " -Wall" -- see "groff" below
|
||||||
@ -128,7 +126,10 @@ main = do
|
|||||||
-- Option arguments should be kept adjacent to their flag or this will go wrong.
|
-- Option arguments should be kept adjacent to their flag or this will go wrong.
|
||||||
(opts, args) <- partition ("-" `isPrefixOf`) <$> getArgs
|
(opts, args) <- partition ("-" `isPrefixOf`) <$> getArgs
|
||||||
let
|
let
|
||||||
ruleoptnames = [ "--commit" ]
|
ruleoptnames = [
|
||||||
|
"--commit", "-c"
|
||||||
|
,"--dry-run", "--dry", "-n"
|
||||||
|
]
|
||||||
(ruleopts, shakeopts) = partition (`elem` ruleoptnames) opts
|
(ruleopts, shakeopts) = partition (`elem` ruleoptnames) opts
|
||||||
(shakearg, ruleargs) = splitAt 1 args
|
(shakearg, ruleargs) = splitAt 1 args
|
||||||
shakeargs = shakeopts ++ shakearg
|
shakeargs = shakeopts ++ shakearg
|
||||||
@ -143,7 +144,7 @@ main = do
|
|||||||
|
|
||||||
want ["help"]
|
want ["help"]
|
||||||
|
|
||||||
phony "help" $ liftIO $ putStrLn usage
|
phony "help" $ liftIO $ putStr usage
|
||||||
|
|
||||||
-- NAMES, FILES, URIS..
|
-- NAMES, FILES, URIS..
|
||||||
|
|
||||||
@ -419,10 +420,6 @@ main = do
|
|||||||
|
|
||||||
-- update all changelogs with latest commits
|
-- update all changelogs with latest commits
|
||||||
phony "changelogs" $ need changelogs
|
phony "changelogs" $ need changelogs
|
||||||
phony "changelogs-dry" $ need $ map (++"-dry") changelogs
|
|
||||||
|
|
||||||
-- show the changelogs updates that would be written
|
|
||||||
-- phony "changelogs-dry" $ need changelogsdry
|
|
||||||
|
|
||||||
-- [PKG/]CHANGES.md
|
-- [PKG/]CHANGES.md
|
||||||
-- Add any new non-boring commits to the specified changelog, in
|
-- Add any new non-boring commits to the specified changelog, in
|
||||||
@ -444,15 +441,12 @@ main = do
|
|||||||
-- package has a release version set, otherwise a dev heading
|
-- package has a release version set, otherwise a dev heading
|
||||||
-- with the current HEAD revision).
|
-- with the current HEAD revision).
|
||||||
--
|
--
|
||||||
-- [PKG/]CHANGES.md-dry
|
-- With --dry-run, print new content to stdout instead of
|
||||||
-- When invoked with -dry suffix, don't update the changelog;
|
-- updating the changelog.
|
||||||
-- just print the items to stdout.
|
|
||||||
--
|
--
|
||||||
phonys (\out' -> if
|
phonys (\out -> if
|
||||||
| not $ out' `elem` (changelogs ++ map (++"-dry") changelogs) -> Nothing
|
| not $ out `elem` changelogs -> Nothing
|
||||||
| otherwise -> Just $ do
|
| otherwise -> Just $ do
|
||||||
let (out, dryrun) | "-dry" `isSuffixOf` out' = (take (length out' - 4) out', True)
|
|
||||||
| otherwise = (out', False)
|
|
||||||
oldlines <- liftIO $ lines <$> readFileStrictly out
|
oldlines <- liftIO $ lines <$> readFileStrictly out
|
||||||
let
|
let
|
||||||
(preamble, oldheading:rest) = span isnotheading oldlines
|
(preamble, oldheading:rest) = span isnotheading oldlines
|
||||||
@ -489,6 +483,7 @@ main = do
|
|||||||
,if isCommitHash changelogversion then [] else [oldheading]
|
,if isCommitHash changelogversion then [] else [oldheading]
|
||||||
,rest
|
,rest
|
||||||
]
|
]
|
||||||
|
dryrun = any (`elem` ruleopts) ["--dry-run", "--dry", "-n"]
|
||||||
|
|
||||||
liftIO $ if
|
liftIO $ if
|
||||||
| lastrev == newrev -> putStrLn $ out ++ ": up to date"
|
| lastrev == newrev -> putStrLn $ out ++ ": up to date"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user