Skip to content

Commit a019891

Browse files
Reorder service chapters: place "Closed Issues without User Defined Labels" immediately after user-defined chapters (#248)
* Initial plan * Implement chapter reordering for issue #75 - Modified ServiceChapters.to_string() to support excluding specific chapters - Added ServiceChapters.get_chapter_string() to retrieve individual chapter strings - Updated ReleaseNotesBuilder.build() to place "Closed Issues without User Defined Labels" chapter immediately after user-defined chapters - Updated all test expectations to reflect the new chapter ordering - All tests passing, Black formatted, Pylint 9.97/10, mypy clean Co-authored-by: miroslavpojer <[email protected]> * Update documentation and examples for new chapter ordering - Updated service_chapters.md to document the new ordering with "Closed Issues without User Defined Labels" appearing first - Updated example output files to reflect the new chapter order - Added explicit note about chapter ordering in the Service Chapter Set section Co-authored-by: miroslavpojer <[email protected]> * Refactor: Use internally defined chapter order in ServiceChapters - Added chapter_order list in ServiceChapters.__init__ to define rendering sequence - Updated to_string() to iterate through chapter_order instead of self.chapters.values() - Removed special handling from ReleaseNotesBuilder - ordering is now self-contained - This approach is more maintainable and flexible for future chapter order changes Addresses review feedback from @miroslavpojer Co-authored-by: miroslavpojer <[email protected]> * Fix: Update service chapters documentation and add error logging for missing chapters --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: miroslavpojer <[email protected]> Co-authored-by: miroslavpojer <[email protected]>
1 parent 7ed5623 commit a019891

File tree

5 files changed

+99
-70
lines changed

5 files changed

+99
-70
lines changed

docs/features/service_chapters.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,27 @@ Highlight quality gaps or inconsistencies in the release scope: missing PR for c
66
## How It Works
77
- Enabled when input `warnings` is `true` (default). When `false`, service chapters are omitted entirely.
88
- Builds a fixed set of diagnostic chapters after custom (user-defined) chapters are rendered.
9+
- The "Closed Issues without User Defined Labels" chapter appears immediately after user-defined chapters, followed by the remaining service chapters.
910
- Honors `print-empty-chapters` (default `true`) to either show or suppress empty diagnostic sections.
1011
- Respects `duplicity-scope`: if duplicates not allowed in Service chapters (`duplicity-scope` excludes `service`/`both`), a record appears only once.
1112
- Skipped records (Skip Labels) are not considered.
1213
- 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).
1314

1415
### Service Chapter Set
16+
The service chapters appear in the following order in the generated release notes:
17+
18+
1. **Closed Issues without User Defined Labels ⚠️** (appears first, immediately after user-defined chapters)
19+
2. Closed Issues without Pull Request ⚠️
20+
3. Merged PRs without Issue and User Defined Labels ⚠️
21+
4. Closed PRs without Issue and User Defined Labels ⚠️
22+
5. Merged PRs Linked to 'Not Closed' Issue ⚠️
23+
6. Direct commits ⚠️
24+
7. Others - No Topic ⚠️
25+
1526
| Chapter Title | Condition Reported |
1627
|---------------|------------------------------------------------------------------------|
28+
| **Closed Issues without User Defined Labels ⚠️** | Closed issue missing all user-defined chapter labels |
1729
| Closed Issues without Pull Request ⚠️ | Closed issue with zero linked PRs |
18-
| Closed Issues without User Defined Labels ⚠️ | Closed issue missing all user-defined chapter labels |
1930
| Merged PRs without Issue and User Defined Labels ⚠️ | Merged PR with no linked issue and none of the user-defined labels |
2031
| Closed PRs without Issue and User Defined Labels ⚠️ | Closed (not merged) PR missing issue link and user-defined labels |
2132
| 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:
7081

7182
## Example Result
7283
```markdown
73-
### Closed Issues without Pull Request ⚠️
74-
All closed issues linked to a Pull Request.
75-
7684
### Closed Issues without User Defined Labels ⚠️
7785
- N/A: #129 _PoC: attempt to do chrome negotiation on a get enpoint_ in #143
7886
- Added Option for AWS SSM Paramter Store as alternative to AWS Secrets manager for storing credentials
7987
- Updated Tests to support the new addition
8088
- Updated ReadMe to indicate how to implement.
8189
90+
### Closed Issues without Pull Request ⚠️
91+
All closed issues linked to a Pull Request.
92+
8293
### Direct commits ⚠️
8394
All direct commits are linked pull requests.
8495
```
85-
(Excerpt; remaining chapters omitted for brevity.)
96+
**Excerpt:** Remaining chapters omitted for brevity.
8697

8798
## Related Features
8899
- [Duplicity Handling](./duplicity_handling.md) – controls duplicate visibility and icons.

examples/output_example_no_hierarchy.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ No entries detected.
1515
- Test release notes nr1
1616
- Test release notes nr2
1717

18-
### Closed Issues without Pull Request ⚠️
19-
- #3 _FEAT: User Authentication_
20-
- #4 _FEAT: Book Browsing_
21-
- #6 _FEAT: Shopping Cart_
22-
- #37 _Example Issue without PR_
23-
- #38 _Example Issue without Release notes comment_
24-
- #88 _Test issue_
25-
2618
### Closed Issues without User Defined Labels ⚠️
2719
- #1 _Initial version of project_ in [#2](https://github.com/company/test-project/pull/2)
2820
- #7 _REQ: User Login Functionality_ in [#13](https://github.com/company/test-project/pull/13)
@@ -35,6 +27,14 @@ No entries detected.
3527
- #29 _Introduce workflow logic for Release notes_ in [#28](https://github.com/company/test-project/pull/28)
3628
- #30 _Introduce Release notes logic_ in [#32](https://github.com/company/test-project/pull/32)
3729

30+
### Closed Issues without Pull Request ⚠️
31+
- #3 _FEAT: User Authentication_
32+
- #4 _FEAT: Book Browsing_
33+
- #6 _FEAT: Shopping Cart_
34+
- #37 _Example Issue without PR_
35+
- #38 _Example Issue without Release notes comment_
36+
- #88 _Test issue_
37+
3838
### Merged PRs without Issue and User Defined Labels ⚠️
3939
- PR: #5 _BugFix - correct Issue GH folder location_
4040
- PR: #16 _repository improvement_

examples/output_example_with_hierarchy.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ No entries detected.
1717
- Test release notes nr1
1818
- Test release notes nr2
1919

20-
### Closed Issues without Pull Request ⚠️
21-
- #3 _FEAT: User Authentication_
22-
- #4 _FEAT: Book Browsing_
23-
- #6 _FEAT: Shopping Cart_
24-
- #37 _Example Issue without PR_
25-
- #38 _Example Issue without Release notes comment_
26-
- #88 _Test issue_
27-
2820
### Closed Issues without User Defined Labels ⚠️
2921
- #1 _Initial version of project_ in [#2](https://github.com/company/test-project/pull/2)
3022
- #7 _REQ: User Login Functionality_ in [#13](https://github.com/company/test-project/pull/13)
@@ -37,6 +29,14 @@ No entries detected.
3729
- #29 _Introduce workflow logic for Release notes_ in [#28](https://github.com/company/test-project/pull/28)
3830
- #30 _Introduce Release notes logic_ in [#32](https://github.com/company/test-project/pull/32)
3931

32+
### Closed Issues without Pull Request ⚠️
33+
- #3 _FEAT: User Authentication_
34+
- #4 _FEAT: Book Browsing_
35+
- #6 _FEAT: Shopping Cart_
36+
- #37 _Example Issue without PR_
37+
- #38 _Example Issue without Release notes comment_
38+
- #88 _Test issue_
39+
4040
### Merged PRs without Issue and User Defined Labels ⚠️
4141
- PR: #5 _BugFix - correct Issue GH folder location_
4242
- PR: #16 _repository improvement_

release_notes_generator/chapters/service_chapters.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ def __init__(
9393
title=OTHERS_NO_TOPIC, empty_message="Previous filters caught all Issues or Pull Requests."
9494
),
9595
}
96+
97+
# Define the order in which service chapters should appear in the output
98+
self.chapter_order = [
99+
CLOSED_ISSUES_WITHOUT_USER_DEFINED_LABELS,
100+
CLOSED_ISSUES_WITHOUT_PULL_REQUESTS,
101+
MERGED_PRS_WITHOUT_ISSUE_AND_USER_DEFINED_LABELS,
102+
CLOSED_PRS_WITHOUT_ISSUE_AND_USER_DEFINED_LABELS,
103+
MERGED_PRS_LINKED_TO_NOT_CLOSED_ISSUES,
104+
DIRECT_COMMITS,
105+
OTHERS_NO_TOPIC,
106+
]
107+
96108
self.show_chapter_closed_issues_without_pull_requests = True
97109
self.show_chapter_closed_issues_without_user_defined_labels = True
98110
self.show_chapter_merged_pr_without_issue_and_labels = True
@@ -299,14 +311,20 @@ def duplicity_allowed() -> bool:
299311
def to_string(self) -> str:
300312
"""
301313
Converts the chapters to a string, excluding hidden chapters.
314+
Chapters are rendered in the order defined by self.chapter_order.
302315
303316
@return: The chapters as a string.
304317
"""
305318
result = ""
306-
for chapter in self.chapters.values():
319+
for chapter_title in self.chapter_order:
307320
# Skip chapters that are in the hidden list
308-
if chapter.title in self.hidden_chapters:
309-
logger.debug("Skipping hidden service chapter: %s", chapter.title)
321+
if chapter_title in self.hidden_chapters:
322+
logger.debug("Skipping hidden service chapter: %s", chapter_title)
323+
continue
324+
325+
chapter = self.chapters.get(chapter_title)
326+
if chapter is None:
327+
logger.error("Chapter %s not found in chapters dictionary.", chapter_title)
310328
continue
311329

312330
chapter_string = chapter.to_string(

tests/unit/release_notes_generator/builder/test_release_notes_builder.py

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@
9292
### Bugfixes 🛠
9393
No entries detected.
9494
95-
### Closed Issues without Pull Request ⚠️
96-
All closed issues linked to a Pull Request.
97-
9895
### Closed Issues without User Defined Labels ⚠️
9996
All closed issues contain at least one of user defined labels.
10097
98+
### Closed Issues without Pull Request ⚠️
99+
All closed issues linked to a Pull Request.
100+
101101
### Merged PRs without Issue and User Defined Labels ⚠️
102102
All merged PRs are linked to issues.
103103
@@ -151,12 +151,12 @@
151151
http://example.com/changelog
152152
"""
153153

154-
RELEASE_NOTES_DATA_HIERARCHY_NO_LABELS_NO_TYPE = """### Closed Issues without Pull Request ⚠️
155-
- N/A: #121 _Fix the bug_ developed by @user in
154+
RELEASE_NOTES_DATA_HIERARCHY_NO_LABELS_NO_TYPE = """### Closed Issues without User Defined Labels ⚠️
155+
- 🔔 N/A: #121 _Fix the bug_ developed by @user in
156156
- Solo issue release note
157157
158-
### Closed Issues without User Defined Labels ⚠️
159-
- 🔔 N/A: #121 _Fix the bug_ developed by @user in
158+
### Closed Issues without Pull Request ⚠️
159+
- N/A: #121 _Fix the bug_ developed by @user in
160160
- Solo issue release note
161161
162162
### Merged PRs without Issue and User Defined Labels ⚠️
@@ -253,13 +253,13 @@
253253
+ More nice code
254254
* Awesome architecture
255255
256+
### Closed Issues without User Defined Labels ⚠️
257+
All closed issues contain at least one of user defined labels.
258+
256259
### Closed Issues without Pull Request ⚠️
257260
- N/A: #121 _Fix the bug_ developed by @user in
258261
- Solo issue release note
259262
260-
### Closed Issues without User Defined Labels ⚠️
261-
All closed issues contain at least one of user defined labels.
262-
263263
### Merged PRs without Issue and User Defined Labels ⚠️
264264
- PR: #124 _Fixed bug_ developed by @user
265265
- Fixed bug
@@ -313,13 +313,13 @@
313313
+ More nice code
314314
* Awesome architecture
315315
316+
### Closed Issues without User Defined Labels ⚠️
317+
All closed issues contain at least one of user defined labels.
318+
316319
### Closed Issues without Pull Request ⚠️
317320
- Feature: #121 _Fix the bug_ developed by @user in
318321
- Solo issue release note
319322
320-
### Closed Issues without User Defined Labels ⚠️
321-
All closed issues contain at least one of user defined labels.
322-
323323
### Merged PRs without Issue and User Defined Labels ⚠️
324324
- PR: #124 _Fixed bug_ developed by @user
325325
- Fixed bug
@@ -384,13 +384,13 @@
384384
+ More nice code
385385
* Awesome architecture
386386
387+
### Closed Issues without User Defined Labels ⚠️
388+
All closed issues contain at least one of user defined labels.
389+
387390
### Closed Issues without Pull Request ⚠️
388391
- Bug: #121 _Fix the bug_ developed by @user in
389392
- Solo issue release note
390393
391-
### Closed Issues without User Defined Labels ⚠️
392-
All closed issues contain at least one of user defined labels.
393-
394394
### Merged PRs without Issue and User Defined Labels ⚠️
395395
- PR: #124 _Fixed bug_ developed by @user
396396
- Fixed bug
@@ -413,13 +413,7 @@
413413
"""
414414

415415

416-
RELEASE_NOTES_NO_DATA_HIERARCHY_NO_LABELS_NO_TYPE = """### Closed Issues without Pull Request ⚠️
417-
- N/A: #121 _Fix the bug_ in
418-
- Solo issue release note
419-
- #450 _SI450 closed_ in
420-
- Hierarchy level release note
421-
422-
### Closed Issues without User Defined Labels ⚠️
416+
RELEASE_NOTES_NO_DATA_HIERARCHY_NO_LABELS_NO_TYPE = """### Closed Issues without User Defined Labels ⚠️
423417
- 🔔 N/A: #121 _Fix the bug_ in
424418
- Solo issue release note
425419
- 🔔 Task: #450 _SI450 closed_ in
@@ -443,6 +437,12 @@
443437
+ More nice code
444438
* Awesome architecture
445439
440+
### Closed Issues without Pull Request ⚠️
441+
- N/A: #121 _Fix the bug_ in
442+
- Solo issue release note
443+
- #450 _SI450 closed_ in
444+
- Hierarchy level release note
445+
446446
### Merged PRs without Issue and User Defined Labels ⚠️
447447
- PR: #124 _Fixed bug_
448448
- Fixed bug
@@ -476,12 +476,6 @@
476476
+ More nice code
477477
* Awesome architecture
478478
479-
### Closed Issues without Pull Request ⚠️
480-
- #121 _Fix the bug_ in
481-
- Solo issue release note
482-
- #450 _SI450 closed_ in
483-
- Hierarchy level release note
484-
485479
### Closed Issues without User Defined Labels ⚠️
486480
- 🔔 #450 _SI450 closed_ in
487481
- Hierarchy level release note
@@ -504,6 +498,12 @@
504498
+ More nice code
505499
* Awesome architecture
506500
501+
### Closed Issues without Pull Request ⚠️
502+
- #121 _Fix the bug_ in
503+
- Solo issue release note
504+
- #450 _SI450 closed_ in
505+
- Hierarchy level release note
506+
507507
### Merged PRs without Issue and User Defined Labels ⚠️
508508
- PR: #124 _Fixed bug_
509509
- Fixed bug
@@ -526,13 +526,7 @@
526526
"""
527527

528528

529-
RELEASE_NOTES_NO_DATA_HIERARCHY_NO_LABELS_WITH_TYPE = """### Closed Issues without Pull Request ⚠️
530-
- #121 _Fix the bug_ in
531-
- Solo issue release note
532-
- #450 _SI450 closed_ in
533-
- Hierarchy level release note
534-
535-
### Closed Issues without User Defined Labels ⚠️
529+
RELEASE_NOTES_NO_DATA_HIERARCHY_NO_LABELS_WITH_TYPE = """### Closed Issues without User Defined Labels ⚠️
536530
- 🔔 #450 _SI450 closed_ in
537531
- Hierarchy level release note
538532
- #451 _SI451 closed_ in #150
@@ -554,6 +548,12 @@
554548
+ More nice code
555549
* Awesome architecture
556550
551+
### Closed Issues without Pull Request ⚠️
552+
- #121 _Fix the bug_ in
553+
- Solo issue release note
554+
- #450 _SI450 closed_ in
555+
- Hierarchy level release note
556+
557557
### Merged PRs without Issue and User Defined Labels ⚠️
558558
- PR: #124 _Fixed bug_
559559
- Fixed bug
@@ -587,12 +587,6 @@
587587
+ More nice code
588588
* Awesome architecture
589589
590-
### Closed Issues without Pull Request ⚠️
591-
- #121 _Fix the bug_ in
592-
- Solo issue release note
593-
- #450 _SI450 closed_ in
594-
- Hierarchy level release note
595-
596590
### Closed Issues without User Defined Labels ⚠️
597591
- 🔔 #450 _SI450 closed_ in
598592
- Hierarchy level release note
@@ -615,6 +609,12 @@
615609
+ More nice code
616610
* Awesome architecture
617611
612+
### Closed Issues without Pull Request ⚠️
613+
- #121 _Fix the bug_ in
614+
- Solo issue release note
615+
- #450 _SI450 closed_ in
616+
- Hierarchy level release note
617+
618618
### Merged PRs without Issue and User Defined Labels ⚠️
619619
- PR: #124 _Fixed bug_
620620
- Fixed bug
@@ -682,12 +682,12 @@
682682
http://example.com/changelog
683683
"""
684684

685-
RELEASE_NOTES_DATA_SERVICE_CHAPTERS_CLOSED_ISSUE_NO_PR_NO_USER_LABELS = """### Closed Issues without Pull Request ⚠️
686-
- N/A: #121 _Fix the bug_ developed by @user in
687-
688-
### Closed Issues without User Defined Labels ⚠️
685+
RELEASE_NOTES_DATA_SERVICE_CHAPTERS_CLOSED_ISSUE_NO_PR_NO_USER_LABELS = """### Closed Issues without User Defined Labels ⚠️
689686
- 🔔 N/A: #121 _Fix the bug_ developed by @user in
690687
688+
### Closed Issues without Pull Request ⚠️
689+
- N/A: #121 _Fix the bug_ developed by @user in
690+
691691
#### Full Changelog
692692
http://example.com/changelog
693693
"""

0 commit comments

Comments
 (0)