Skip to content

Commit 1a2ea4f

Browse files
#195 - Update rules for service chapter "Merged PRs Linked to 'Not Cl… (#196)
#195 - Update rules for service chapter "Merged PRs Linked to 'Not Closed' Issue" - Improved rules for deciding when hierarchy issue can be included into service chapter "Merged PRs Linked to 'Not Closed' Issue". Hierarchy issue can be open when cotains merged PRs.
1 parent 80b27be commit 1a2ea4f

File tree

2 files changed

+25
-104
lines changed

2 files changed

+25
-104
lines changed

release_notes_generator/chapters/service_chapters.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@
1818
This module contains the ServiceChapters class which is responsible for representing the service chapters in the release
1919
notes.
2020
"""
21+
import logging
2122
from typing import Optional, cast
2223

2324
from release_notes_generator.action_inputs import ActionInputs
2425
from release_notes_generator.chapters.base_chapters import BaseChapters
2526
from release_notes_generator.model.chapter import Chapter
2627
from release_notes_generator.model.record.commit_record import CommitRecord
28+
from release_notes_generator.model.record.hierarchy_issue_record import HierarchyIssueRecord
2729
from release_notes_generator.model.record.issue_record import IssueRecord
2830
from release_notes_generator.model.record.pull_request_record import PullRequestRecord
2931
from release_notes_generator.model.record.record import Record
32+
from release_notes_generator.model.record.sub_issue_record import SubIssueRecord
3033
from release_notes_generator.utils.constants import (
3134
CLOSED_ISSUES_WITHOUT_PULL_REQUESTS,
3235
CLOSED_ISSUES_WITHOUT_USER_DEFINED_LABELS,
@@ -38,6 +41,8 @@
3841
)
3942
from release_notes_generator.utils.enums import DuplicityScopeEnum
4043

44+
logger = logging.getLogger(__name__)
45+
4146

4247
# pylint: disable=too-many-instance-attributes
4348
class ServiceChapters(BaseChapters):
@@ -121,20 +126,23 @@ def populate(self, records: dict[str, Record]) -> None:
121126

122127
# other edge case situations
123128
else:
124-
if (
125-
record.is_open
126-
and isinstance(record, IssueRecord)
127-
and cast(IssueRecord, record).pull_requests_count() == 0
128-
):
129-
# no change increment delivered
130-
pass
131-
elif (
132-
record.is_open
133-
and isinstance(record, IssueRecord)
134-
and cast(IssueRecord, record).pull_requests_count() > 0
135-
):
136-
self.chapters[MERGED_PRS_LINKED_TO_NOT_CLOSED_ISSUES].add_row(record_id, record.to_chapter_row())
137-
self.used_record_numbers.append(record_id)
129+
pr_count = cast(IssueRecord, record).pull_requests_count()
130+
is_issue_like = isinstance(record, (IssueRecord, SubIssueRecord))
131+
is_hierarchy = isinstance(record, HierarchyIssueRecord)
132+
133+
if record.is_open:
134+
if is_hierarchy and record.is_present_in_chapters:
135+
logger.debug("Skipping open HierarchyIssueRecord %s (pr_count=%d)", record_id, pr_count)
136+
elif is_issue_like and pr_count > 0:
137+
# Open issue/sub-issue with linked PRs → add to the specific chapter
138+
self.chapters[MERGED_PRS_LINKED_TO_NOT_CLOSED_ISSUES].add_row(
139+
record_id, record.to_chapter_row()
140+
)
141+
logger.debug("Linked PRs for open issue %s; added to chapter.", record_id)
142+
self.used_record_numbers.append(record_id)
143+
else:
144+
# Open issue/sub-issue with no PRs → explicitly do nothing (keeps original behavior)
145+
pass
138146
else:
139147
if record_id not in self.used_record_numbers:
140148
self.chapters[OTHERS_NO_TOPIC].add_row(record_id, record.to_chapter_row())

tests/release_notes/builder/test_release_notes_builder.py

Lines changed: 3 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -269,36 +269,7 @@
269269
All closed PRs are linked to issues.
270270
271271
### Merged PRs Linked to 'Not Closed' Issue ⚠️
272-
- 🔔 None: _HI302 open_ #302
273-
- _Release Notes_:
274-
- Hierarchy level release note
275-
- 🔔 N/A: #451 _SI451 closed_ developed by @pr_author_101, @user in #150
276-
- Hierarchy level release note
277-
- Fixed bug
278-
- Improved performance
279-
+ More nice code
280-
* Awesome architecture
281-
- 🔔 None: _HI303 open_ #303
282-
- _Release Notes_:
283-
- Hierarchy level release note
284-
- 🔔 N/A: #452 _SI452 closed_ developed by @author, @pr_author_101, @user in #151
285-
- Hierarchy level release note
286-
- Fixed bug
287-
- Improved performance
288-
+ More nice code
289-
* Awesome architecture
290-
- 🔔 None: _HI304 open_ #304
291-
- _Release Notes_:
292-
- Hierarchy level release note
293-
- 🔔 None: _HI350 open_ #350
294-
- _Release Notes_:
295-
- Sub-hierarchy level release note
296-
- 🔔 N/A: #453 _SI453 closed_ developed by @author, @pr_author_101, @user in #152
297-
- Hierarchy level release note
298-
- Fixed bug
299-
- Improved performance
300-
+ More nice code
301-
* Awesome architecture
272+
All merged PRs are linked to Closed issues.
302273
303274
### Direct commits ⚠️
304275
- Commit: merge_c... - Direct commit example
@@ -362,36 +333,7 @@
362333
* Awesome architecture
363334
364335
### Merged PRs Linked to 'Not Closed' Issue ⚠️
365-
- 🔔 Epic: _HI302 open_ #302
366-
- _Release Notes_:
367-
- Hierarchy level release note
368-
- 🔔 Task: #451 _SI451 closed_ developed by @pr_author_101, @user in #150
369-
- Hierarchy level release note
370-
- Fixed bug
371-
- Improved performance
372-
+ More nice code
373-
* Awesome architecture
374-
- 🔔 Epic: _HI303 open_ #303
375-
- _Release Notes_:
376-
- Hierarchy level release note
377-
- 🔔 Task: #452 _SI452 closed_ developed by @author, @pr_author_101, @user in #151
378-
- Hierarchy level release note
379-
- Fixed bug
380-
- Improved performance
381-
+ More nice code
382-
* Awesome architecture
383-
- 🔔 Epic: _HI304 open_ #304
384-
- _Release Notes_:
385-
- Hierarchy level release note
386-
- 🔔 Feature: _HI350 open_ #350
387-
- _Release Notes_:
388-
- Sub-hierarchy level release note
389-
- 🔔 Task: #453 _SI453 closed_ developed by @author, @pr_author_101, @user in #152
390-
- Hierarchy level release note
391-
- Fixed bug
392-
- Improved performance
393-
+ More nice code
394-
* Awesome architecture
336+
All merged PRs are linked to Closed issues.
395337
396338
### Direct commits ⚠️
397339
- Commit: merge_c... - Direct commit example
@@ -458,36 +400,7 @@
458400
All closed PRs are linked to issues.
459401
460402
### Merged PRs Linked to 'Not Closed' Issue ⚠️
461-
- 🔔 Epic: _HI302 open_ #302
462-
- _Release Notes_:
463-
- Hierarchy level release note
464-
- 🔔 Task: #451 _SI451 closed_ developed by @pr_author_101, @user in #150
465-
- Hierarchy level release note
466-
- Fixed bug
467-
- Improved performance
468-
+ More nice code
469-
* Awesome architecture
470-
- 🔔 Epic: _HI303 open_ #303
471-
- _Release Notes_:
472-
- Hierarchy level release note
473-
- 🔔 Task: #452 _SI452 closed_ developed by @author, @pr_author_101, @user in #151
474-
- Hierarchy level release note
475-
- Fixed bug
476-
- Improved performance
477-
+ More nice code
478-
* Awesome architecture
479-
- 🔔 Epic: _HI304 open_ #304
480-
- _Release Notes_:
481-
- Hierarchy level release note
482-
- 🔔 Feature: _HI350 open_ #350
483-
- _Release Notes_:
484-
- Sub-hierarchy level release note
485-
- 🔔 Task: #453 _SI453 closed_ developed by @author, @pr_author_101, @user in #152
486-
- Hierarchy level release note
487-
- Fixed bug
488-
- Improved performance
489-
+ More nice code
490-
* Awesome architecture
403+
All merged PRs are linked to Closed issues.
491404
492405
### Direct commits ⚠️
493406
- Commit: merge_c... - Direct commit example

0 commit comments

Comments
 (0)