Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to omit empty sections from getChangelog task. #167

Closed
ChrisCarini opened this issue Apr 30, 2023 · 0 comments
Closed

Add flag to omit empty sections from getChangelog task. #167

ChrisCarini opened this issue Apr 30, 2023 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@ChrisCarini
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Similar to https://github.com/JetBrains/intellij-platform-plugin-template/blob/main/.github/workflows/build.yml#L166 , several of my OSS plugins also create a draft release using the getChangelog output. Every time I do a release, I have to edit the description and delete empty sections to keep the release notes (and changelog) short and simple. I'd rather have this automated, so that when the PR is opened, the empty sections are already removed - because I, along with many others, leverage this gradle plugin, I would like to pass a flag to this task to tell it to omit empty changelogs.

Describe the solution you'd like

A flag, such as --no-empty-secions, to omit empty sections from the output of getChangelog task.

Describe alternatives you've considered

awk, but it's ugly (there is probably a better, more concise way; this is what I ended up w/ after 30 min of googling):

./gradlew getChangelog --unreleased --no-header --console=plain -q  | awk 'function flush_print_maybe() {
                      if (matching > 2) printf("%s\n", buf)
                      buf = ""
                  }
                  /###/ { flush_print_maybe(); matching = 1 }
                  /^$/  { flush_print_maybe(); matching = 0 }
                  /.+/  { matching++ }
                  matching { buf = (buf == "" ? $0 : buf ORS $0) }
                  END   { flush_print_maybe() }'

Additional context

┌─(ChrisCarini)──(2023-04-29 @ 22:50:16)──( ~/GitHub/jetbrains/plugins/sample-intellij-plugin  (main) ) 
└─$ > ./gradlew getChangelog --unreleased --no-header --no-links --no-empty-sections --console=plain -q 
### Changed
- Upgrading IntelliJ from 2023.1 to 2023.1.1

### Deprecated
- Deprecated line


┌─(ChrisCarini)──(2023-04-29 @ 22:50:19)──( ~/GitHub/jetbrains/plugins/sample-intellij-plugin  (main) ) 
└─$ >

...vs...

┌─(ChrisCarini)──(2023-04-29 @ 22:50:19)──( ~/GitHub/jetbrains/plugins/sample-intellij-plugin  (main) ) 
└─$ > ./gradlew getChangelog --unreleased --no-header --no-links --console=plain -q 
### Added

### Changed
- Upgrading IntelliJ from 2023.1 to 2023.1.1

### Deprecated
- Deprecated line

### Removed

### Fixed

### Security


┌─(ChrisCarini)──(2023-04-29 @ 22:50:28)──( ~/GitHub/jetbrains/plugins/sample-intellij-plugin  (main) ) 
└─$ > 
@ChrisCarini ChrisCarini added the enhancement New feature or request label Apr 30, 2023
@hsz hsz closed this as completed in a94247b Jun 1, 2023
@hsz hsz added this to the next milestone Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants