diff --git a/NEWS.md b/NEWS.md index 9c62b10..2b01e10 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Changed +- **release.sh**: Remove noise (empty headings) in **NEWS.md** at release time + ### Removed ## [1.6] - 2023-07-14 @@ -22,40 +24,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - Use command `opam env --switch=$it --set-switch`, so the env var `$OPAMSWITCH` is also set -### Fixed - -### Changed - -### Removed - ## [1.5] - 2023-07-12 -### Added - -### Fixed - ### Changed - **README.md**: Use vanilla (not GitHub-flavored) Markdown syntax for snippets - Replace (redraw-display) with (force-mode-line-update t) - Memoize (opam-switch-mode-lighter) to speed-up mode-line updates -### Removed - ## [1.4] - 2023-07-11 ### Added - (opam-switch-mode-lighter): Indicate the switch name in the minibuffer, closes [#11](https://github.com/ProofGeneral/opam-switch-mode/issues/11) -### Fixed - ### Changed - **README.md**: Document the feature from [1.3] -### Removed - ## [1.3] - 2023-07-11 ### Added @@ -63,12 +49,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - New hook: opam-switch-before-change-opam-switch-hook - (opam-switch-set-switch): Call (run-hooks 'opam-switch-before-change-opam-switch-hook) before changing the env -### Fixed - -### Changed - -### Removed - ## [1.2] - 2023-07-11 ### Added @@ -88,8 +68,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - Change mode-bar's first element, so it expands to "OPSW - Opam Switch Mode" - **release.sh**: auto-update **NEWS.md** -### Removed - ## [1.1] - 2023-06-20 ### Added @@ -100,10 +78,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - tweaks and cleanups by [**@monnier**](https://github.com/monnier) -### Changed - -### Removed - ## [1.0] - 2022-11-15 - Initial release, distributed on MELPA. diff --git a/release.sh b/release.sh index 3ead57f..af07062 100755 --- a/release.sh +++ b/release.sh @@ -7,7 +7,8 @@ set -eu perl_replace() { local str1="$1" local str2="$2" - perl -wpe 'BEGIN{$str1=shift @ARGV; $str2=shift @ARGV; $s1=quotemeta($str1); }; s/$s1/$str2/g;' "$str1" "$str2" + local slurp="${3:+0777}" + perl -wp"$slurp"e 'BEGIN{$str1=shift @ARGV; $str2=shift @ARGV; $s1=quotemeta($str1); }; s/$s1/$str2/g;' "$str1" "$str2" } tweak_changelog() { @@ -18,6 +19,24 @@ tweak_changelog() { next_full="## [$next] - $(date -I)" if [ "$step" = '1' ]; then + local replace=( +'### Added + +#' +'### Fixed + +#' +'### Changed + +#' +'### Removed + +#') + local r + for r in "${replace[@]}"; do + cp -f "$file" "$file~" + perl_replace "$r" "#" "slurp" <"$file~" > "$file" + done local line_unreleased line_unreleased=$(grep "$file" -e 'Unreleased.*\.\.\.HEAD') local released_tmp @@ -30,7 +49,7 @@ tweak_changelog() { perl_replace "$line_unreleased" "$released" <"$file~" > "$file" elif [ "$step" = '2' ]; then - local section="## [Unreleased] + local section='## [Unreleased] ### Added @@ -40,12 +59,12 @@ tweak_changelog() { ### Removed -" +' local unreleased="[Unreleased]: https://github.com/ProofGeneral/opam-switch-mode/compare/$next...HEAD" cp -fv "$file" "$file~" perl_replace "$next_full" "$section$next_full" <"$file~" > "$file" cp -fv "$file" "$file~" - perl_replace "" " + perl_replace '' " $unreleased" <"$file~" > "$file" else