Skip to content

Commit

Permalink
chore(release.sh): Remove empty headings from NEWS.md
Browse files Browse the repository at this point in the history
  • Loading branch information
erikmd committed Jul 14, 2023
1 parent 3a17a95 commit d095d0e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 32 deletions.
30 changes: 2 additions & 28 deletions NEWS.md
Expand Up @@ -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
Expand All @@ -22,53 +24,31 @@ 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

- 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
Expand All @@ -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
Expand All @@ -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.
Expand Down
27 changes: 23 additions & 4 deletions release.sh
Expand Up @@ -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() {
Expand All @@ -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
Expand All @@ -30,7 +49,7 @@ tweak_changelog() {
perl_replace "$line_unreleased" "$released" <"$file~" > "$file"

elif [ "$step" = '2' ]; then
local section="## [Unreleased]
local section='## [Unreleased]
### Added
Expand All @@ -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 "<!-- bottom -->" "<!-- bottom -->
perl_replace '<!-- bottom -->' "<!-- bottom -->
$unreleased" <"$file~" > "$file"

else
Expand Down

0 comments on commit d095d0e

Please sign in to comment.