diff --git a/docs/features/service_chapters.md b/docs/features/service_chapters.md index 333df825..4e994ff1 100644 --- a/docs/features/service_chapters.md +++ b/docs/features/service_chapters.md @@ -6,16 +6,27 @@ Highlight quality gaps or inconsistencies in the release scope: missing PR for c ## How It Works - Enabled when input `warnings` is `true` (default). When `false`, service chapters are omitted entirely. - Builds a fixed set of diagnostic chapters after custom (user-defined) chapters are rendered. +- The "Closed Issues without User Defined Labels" chapter appears immediately after user-defined chapters, followed by the remaining service chapters. - Honors `print-empty-chapters` (default `true`) to either show or suppress empty diagnostic sections. - Respects `duplicity-scope`: if duplicates not allowed in Service chapters (`duplicity-scope` excludes `service`/`both`), a record appears only once. - Skipped records (Skip Labels) are not considered. - Issue ↔ PR linkage here relies on the same detection as main extraction: GitHub closing keywords (e.g. `Fixes #123`) plus API lookups of closing references. See [Issue ↔ PR Linking](../configuration_reference.md#issue--pr-linking). ### Service Chapter Set +The service chapters appear in the following order in the generated release notes: + +1. **Closed Issues without User Defined Labels ⚠️** (appears first, immediately after user-defined chapters) +2. Closed Issues without Pull Request ⚠️ +3. Merged PRs without Issue and User Defined Labels ⚠️ +4. Closed PRs without Issue and User Defined Labels ⚠️ +5. Merged PRs Linked to 'Not Closed' Issue ⚠️ +6. Direct commits ⚠️ +7. Others - No Topic ⚠️ + | Chapter Title | Condition Reported | |---------------|------------------------------------------------------------------------| +| **Closed Issues without User Defined Labels ⚠️** | Closed issue missing all user-defined chapter labels | | Closed Issues without Pull Request ⚠️ | Closed issue with zero linked PRs | -| Closed Issues without User Defined Labels ⚠️ | Closed issue missing all user-defined chapter labels | | Merged PRs without Issue and User Defined Labels ⚠️ | Merged PR with no linked issue and none of the user-defined labels | | Closed PRs without Issue and User Defined Labels ⚠️ | Closed (not merged) PR missing issue link and user-defined labels | | Merged PRs Linked to 'Not Closed' Issue ⚠️ | PR merged while a linked issue is still open | @@ -70,19 +81,19 @@ Or use comma-separated format: ## Example Result ```markdown -### Closed Issues without Pull Request ⚠️ -All closed issues linked to a Pull Request. - ### Closed Issues without User Defined Labels ⚠️ - N/A: #129 _PoC: attempt to do chrome negotiation on a get enpoint_ in #143 - Added Option for AWS SSM Paramter Store as alternative to AWS Secrets manager for storing credentials - Updated Tests to support the new addition - Updated ReadMe to indicate how to implement. +### Closed Issues without Pull Request ⚠️ +All closed issues linked to a Pull Request. + ### Direct commits ⚠️ All direct commits are linked pull requests. ``` -(Excerpt; remaining chapters omitted for brevity.) +**Excerpt:** Remaining chapters omitted for brevity. ## Related Features - [Duplicity Handling](./duplicity_handling.md) – controls duplicate visibility and icons. diff --git a/examples/output_example_no_hierarchy.md b/examples/output_example_no_hierarchy.md index 57f05119..8e17f9ed 100644 --- a/examples/output_example_no_hierarchy.md +++ b/examples/output_example_no_hierarchy.md @@ -15,14 +15,6 @@ No entries detected. - Test release notes nr1 - Test release notes nr2 -### Closed Issues without Pull Request ⚠️ -- #3 _FEAT: User Authentication_ -- #4 _FEAT: Book Browsing_ -- #6 _FEAT: Shopping Cart_ -- #37 _Example Issue without PR_ -- #38 _Example Issue without Release notes comment_ -- #88 _Test issue_ - ### Closed Issues without User Defined Labels ⚠️ - #1 _Initial version of project_ in [#2](https://github.com/company/test-project/pull/2) - #7 _REQ: User Login Functionality_ in [#13](https://github.com/company/test-project/pull/13) @@ -35,6 +27,14 @@ No entries detected. - #29 _Introduce workflow logic for Release notes_ in [#28](https://github.com/company/test-project/pull/28) - #30 _Introduce Release notes logic_ in [#32](https://github.com/company/test-project/pull/32) +### Closed Issues without Pull Request ⚠️ +- #3 _FEAT: User Authentication_ +- #4 _FEAT: Book Browsing_ +- #6 _FEAT: Shopping Cart_ +- #37 _Example Issue without PR_ +- #38 _Example Issue without Release notes comment_ +- #88 _Test issue_ + ### Merged PRs without Issue and User Defined Labels ⚠️ - PR: #5 _BugFix - correct Issue GH folder location_ - PR: #16 _repository improvement_ diff --git a/examples/output_example_with_hierarchy.md b/examples/output_example_with_hierarchy.md index 5bc064cd..7ab74f24 100644 --- a/examples/output_example_with_hierarchy.md +++ b/examples/output_example_with_hierarchy.md @@ -17,14 +17,6 @@ No entries detected. - Test release notes nr1 - Test release notes nr2 -### Closed Issues without Pull Request ⚠️ -- #3 _FEAT: User Authentication_ -- #4 _FEAT: Book Browsing_ -- #6 _FEAT: Shopping Cart_ -- #37 _Example Issue without PR_ -- #38 _Example Issue without Release notes comment_ -- #88 _Test issue_ - ### Closed Issues without User Defined Labels ⚠️ - #1 _Initial version of project_ in [#2](https://github.com/company/test-project/pull/2) - #7 _REQ: User Login Functionality_ in [#13](https://github.com/company/test-project/pull/13) @@ -37,6 +29,14 @@ No entries detected. - #29 _Introduce workflow logic for Release notes_ in [#28](https://github.com/company/test-project/pull/28) - #30 _Introduce Release notes logic_ in [#32](https://github.com/company/test-project/pull/32) +### Closed Issues without Pull Request ⚠️ +- #3 _FEAT: User Authentication_ +- #4 _FEAT: Book Browsing_ +- #6 _FEAT: Shopping Cart_ +- #37 _Example Issue without PR_ +- #38 _Example Issue without Release notes comment_ +- #88 _Test issue_ + ### Merged PRs without Issue and User Defined Labels ⚠️ - PR: #5 _BugFix - correct Issue GH folder location_ - PR: #16 _repository improvement_ diff --git a/release_notes_generator/chapters/service_chapters.py b/release_notes_generator/chapters/service_chapters.py index 4b166ca1..7740504c 100644 --- a/release_notes_generator/chapters/service_chapters.py +++ b/release_notes_generator/chapters/service_chapters.py @@ -93,6 +93,18 @@ def __init__( title=OTHERS_NO_TOPIC, empty_message="Previous filters caught all Issues or Pull Requests." ), } + + # Define the order in which service chapters should appear in the output + self.chapter_order = [ + CLOSED_ISSUES_WITHOUT_USER_DEFINED_LABELS, + CLOSED_ISSUES_WITHOUT_PULL_REQUESTS, + MERGED_PRS_WITHOUT_ISSUE_AND_USER_DEFINED_LABELS, + CLOSED_PRS_WITHOUT_ISSUE_AND_USER_DEFINED_LABELS, + MERGED_PRS_LINKED_TO_NOT_CLOSED_ISSUES, + DIRECT_COMMITS, + OTHERS_NO_TOPIC, + ] + self.show_chapter_closed_issues_without_pull_requests = True self.show_chapter_closed_issues_without_user_defined_labels = True self.show_chapter_merged_pr_without_issue_and_labels = True @@ -299,14 +311,20 @@ def duplicity_allowed() -> bool: def to_string(self) -> str: """ Converts the chapters to a string, excluding hidden chapters. + Chapters are rendered in the order defined by self.chapter_order. @return: The chapters as a string. """ result = "" - for chapter in self.chapters.values(): + for chapter_title in self.chapter_order: # Skip chapters that are in the hidden list - if chapter.title in self.hidden_chapters: - logger.debug("Skipping hidden service chapter: %s", chapter.title) + if chapter_title in self.hidden_chapters: + logger.debug("Skipping hidden service chapter: %s", chapter_title) + continue + + chapter = self.chapters.get(chapter_title) + if chapter is None: + logger.error("Chapter %s not found in chapters dictionary.", chapter_title) continue chapter_string = chapter.to_string( diff --git a/tests/unit/release_notes_generator/builder/test_release_notes_builder.py b/tests/unit/release_notes_generator/builder/test_release_notes_builder.py index 9f8768ca..57da432d 100644 --- a/tests/unit/release_notes_generator/builder/test_release_notes_builder.py +++ b/tests/unit/release_notes_generator/builder/test_release_notes_builder.py @@ -92,12 +92,12 @@ ### Bugfixes 🛠 No entries detected. -### Closed Issues without Pull Request ⚠️ -All closed issues linked to a Pull Request. - ### Closed Issues without User Defined Labels ⚠️ All closed issues contain at least one of user defined labels. +### Closed Issues without Pull Request ⚠️ +All closed issues linked to a Pull Request. + ### Merged PRs without Issue and User Defined Labels ⚠️ All merged PRs are linked to issues. @@ -151,12 +151,12 @@ http://example.com/changelog """ -RELEASE_NOTES_DATA_HIERARCHY_NO_LABELS_NO_TYPE = """### Closed Issues without Pull Request ⚠️ -- N/A: #121 _Fix the bug_ developed by @user in +RELEASE_NOTES_DATA_HIERARCHY_NO_LABELS_NO_TYPE = """### Closed Issues without User Defined Labels ⚠️ +- 🔔 N/A: #121 _Fix the bug_ developed by @user in - Solo issue release note -### Closed Issues without User Defined Labels ⚠️ -- 🔔 N/A: #121 _Fix the bug_ developed by @user in +### Closed Issues without Pull Request ⚠️ +- N/A: #121 _Fix the bug_ developed by @user in - Solo issue release note ### Merged PRs without Issue and User Defined Labels ⚠️ @@ -253,13 +253,13 @@ + More nice code * Awesome architecture +### Closed Issues without User Defined Labels ⚠️ +All closed issues contain at least one of user defined labels. + ### Closed Issues without Pull Request ⚠️ - N/A: #121 _Fix the bug_ developed by @user in - Solo issue release note -### Closed Issues without User Defined Labels ⚠️ -All closed issues contain at least one of user defined labels. - ### Merged PRs without Issue and User Defined Labels ⚠️ - PR: #124 _Fixed bug_ developed by @user - Fixed bug @@ -313,13 +313,13 @@ + More nice code * Awesome architecture +### Closed Issues without User Defined Labels ⚠️ +All closed issues contain at least one of user defined labels. + ### Closed Issues without Pull Request ⚠️ - Feature: #121 _Fix the bug_ developed by @user in - Solo issue release note -### Closed Issues without User Defined Labels ⚠️ -All closed issues contain at least one of user defined labels. - ### Merged PRs without Issue and User Defined Labels ⚠️ - PR: #124 _Fixed bug_ developed by @user - Fixed bug @@ -384,13 +384,13 @@ + More nice code * Awesome architecture +### Closed Issues without User Defined Labels ⚠️ +All closed issues contain at least one of user defined labels. + ### Closed Issues without Pull Request ⚠️ - Bug: #121 _Fix the bug_ developed by @user in - Solo issue release note -### Closed Issues without User Defined Labels ⚠️ -All closed issues contain at least one of user defined labels. - ### Merged PRs without Issue and User Defined Labels ⚠️ - PR: #124 _Fixed bug_ developed by @user - Fixed bug @@ -413,13 +413,7 @@ """ -RELEASE_NOTES_NO_DATA_HIERARCHY_NO_LABELS_NO_TYPE = """### Closed Issues without Pull Request ⚠️ -- N/A: #121 _Fix the bug_ in - - Solo issue release note -- #450 _SI450 closed_ in - - Hierarchy level release note - -### Closed Issues without User Defined Labels ⚠️ +RELEASE_NOTES_NO_DATA_HIERARCHY_NO_LABELS_NO_TYPE = """### Closed Issues without User Defined Labels ⚠️ - 🔔 N/A: #121 _Fix the bug_ in - Solo issue release note - 🔔 Task: #450 _SI450 closed_ in @@ -443,6 +437,12 @@ + More nice code * Awesome architecture +### Closed Issues without Pull Request ⚠️ +- N/A: #121 _Fix the bug_ in + - Solo issue release note +- #450 _SI450 closed_ in + - Hierarchy level release note + ### Merged PRs without Issue and User Defined Labels ⚠️ - PR: #124 _Fixed bug_ - Fixed bug @@ -476,12 +476,6 @@ + More nice code * Awesome architecture -### Closed Issues without Pull Request ⚠️ -- #121 _Fix the bug_ in - - Solo issue release note -- #450 _SI450 closed_ in - - Hierarchy level release note - ### Closed Issues without User Defined Labels ⚠️ - 🔔 #450 _SI450 closed_ in - Hierarchy level release note @@ -504,6 +498,12 @@ + More nice code * Awesome architecture +### Closed Issues without Pull Request ⚠️ +- #121 _Fix the bug_ in + - Solo issue release note +- #450 _SI450 closed_ in + - Hierarchy level release note + ### Merged PRs without Issue and User Defined Labels ⚠️ - PR: #124 _Fixed bug_ - Fixed bug @@ -526,13 +526,7 @@ """ -RELEASE_NOTES_NO_DATA_HIERARCHY_NO_LABELS_WITH_TYPE = """### Closed Issues without Pull Request ⚠️ -- #121 _Fix the bug_ in - - Solo issue release note -- #450 _SI450 closed_ in - - Hierarchy level release note - -### Closed Issues without User Defined Labels ⚠️ +RELEASE_NOTES_NO_DATA_HIERARCHY_NO_LABELS_WITH_TYPE = """### Closed Issues without User Defined Labels ⚠️ - 🔔 #450 _SI450 closed_ in - Hierarchy level release note - #451 _SI451 closed_ in #150 @@ -554,6 +548,12 @@ + More nice code * Awesome architecture +### Closed Issues without Pull Request ⚠️ +- #121 _Fix the bug_ in + - Solo issue release note +- #450 _SI450 closed_ in + - Hierarchy level release note + ### Merged PRs without Issue and User Defined Labels ⚠️ - PR: #124 _Fixed bug_ - Fixed bug @@ -587,12 +587,6 @@ + More nice code * Awesome architecture -### Closed Issues without Pull Request ⚠️ -- #121 _Fix the bug_ in - - Solo issue release note -- #450 _SI450 closed_ in - - Hierarchy level release note - ### Closed Issues without User Defined Labels ⚠️ - 🔔 #450 _SI450 closed_ in - Hierarchy level release note @@ -615,6 +609,12 @@ + More nice code * Awesome architecture +### Closed Issues without Pull Request ⚠️ +- #121 _Fix the bug_ in + - Solo issue release note +- #450 _SI450 closed_ in + - Hierarchy level release note + ### Merged PRs without Issue and User Defined Labels ⚠️ - PR: #124 _Fixed bug_ - Fixed bug @@ -682,12 +682,12 @@ http://example.com/changelog """ -RELEASE_NOTES_DATA_SERVICE_CHAPTERS_CLOSED_ISSUE_NO_PR_NO_USER_LABELS = """### Closed Issues without Pull Request ⚠️ -- N/A: #121 _Fix the bug_ developed by @user in - -### Closed Issues without User Defined Labels ⚠️ +RELEASE_NOTES_DATA_SERVICE_CHAPTERS_CLOSED_ISSUE_NO_PR_NO_USER_LABELS = """### Closed Issues without User Defined Labels ⚠️ - 🔔 N/A: #121 _Fix the bug_ developed by @user in +### Closed Issues without Pull Request ⚠️ +- N/A: #121 _Fix the bug_ developed by @user in + #### Full Changelog http://example.com/changelog """