-
Notifications
You must be signed in to change notification settings - Fork 4
Fix missing sections #492
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
Fix missing sections #492
Conversation
Caution Review failedThe pull request is closed. WalkthroughThis pull request updates both the test suite and the release notes generation functionality. The test file now features a new markdown template, adjusts dependency grouping behavior, and refines assertions for expected output. In the production code, the Changes
Sequence Diagram(s)sequenceDiagram
participant T as Test Caller
participant G as generateReleaseNotes
participant C as collapseSections
participant R as rebuildMarkdown
T->>G: Call generateReleaseNotes(input)
G->>G: Log operations via core.group
alt Collapse sections needed
G->>C: Invoke collapseSections(sections, n)
C-->>G: Return collapsed section data
end
G->>R: Invoke rebuildMarkdown(originalBody, processedSections, categories)
R-->>G: Return updated markdown
G-->>T: Return final release notes
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (2)
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR improves the generation of release notes and refactors related functions to enhance readability and maintainability while adding new tests for comprehensive validation.
- Introduces a rebuildMarkdown function and refactored collapseSections to better handle markdown sections.
- Updates dependency grouping and conventional prefix removal with improved debug logging.
- Enhances test coverage by adding a comprehensive markdown example and new test cases for header, footer, and dependency grouping.
Reviewed Changes
File | Description |
---|---|
src/notes.ts | Refactored release notes generation, including new rebuildMarkdown and collapseSections. |
tests/notes.test.ts | Expanded test cases to validate updated release notes structure and formatting. |
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
src/notes.ts:246
- Directly modifying the first item in modifiedItems may introduce unintended side effects if the original array is used elsewhere. Consider cloning the items array before applying modifications to ensure immutability.
modifiedItems[0] = summaryText + '\n\n' + modifiedItems[0]
tests/notes.test.ts:242
- The assertion to exclude 'revert' may inadvertently filter out valid content if 'revert' appears in other contexts. Consider using a more precise assertion targeting only unwanted revert commit entries.
expect(notes).not.toContain('revert')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
__tests__/notes.test.ts (1)
69-115
: Consider correcting the "fearture" typos in test data.
They won't break functionality, but it might be clearer to use consistent wording like "feature" if it's not intentional.src/notes.ts (1)
218-226
:collapseSections
implementation appears correct, butasync
might be unnecessary.
Currently, there are noawait
calls in this function, so you could simplify the signature if no future async usage is planned.Apply this diff to remove
async
:-async function collapseSections(sections: SectionData, n: number): Promise<SectionData> { +function collapseSections(sections: SectionData, n: number): SectionData {Also applies to: 233-234, 257-257, 262-262
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
dist/index.js
is excluded by!**/dist/**
dist/index.js.map
is excluded by!**/dist/**
,!**/*.map
📒 Files selected for processing (2)
__tests__/notes.test.ts
(5 hunks)src/notes.ts
(3 hunks)
🔇 Additional comments (11)
__tests__/notes.test.ts (5)
174-174
: Change togroupDependencies: false
is clear.
This modification properly tests the scenario where dependency grouping is disabled.
196-198
: New 'revert(bug)' test items look good.
These lines effectively test how the code handles revert prefixes.
242-242
: Verifying absence of "revert" in final output is appropriate.
This ensures conventional prefixes are fully removed when configured.
245-293
: Comprehensive test "should work with all the features enabled" looks solid.
It thoroughly checks combined behaviors of prefix removal, dependency grouping, collapsing sections, and custom header/footer.
329-332
: Additional bullet items are well-structured.
They sufficiently expand coverage for multiple dependency lines in a single section.src/notes.ts (6)
71-73
: Logging the sections after removing prefixes is helpful for debugging.
This grouped debug output will simplify tracking prefix removal issues.
77-79
: Dependency grouping debug output is a welcome addition.
This makes it easier to verify the final grouped output.
83-88
: Conditionally collapsing sections is implemented smoothly.
Collapsing only ifcollapseAfter > 0
is a clear and intuitive approach.
90-91
: Integration of the newrebuildMarkdown
function is seamless.
Rebuilding the final body with processed sections is a neat solution to preserve original content while updating specific parts.
111-121
: Added documentation is concise and helpful.
These docstrings make the release notes transformation process more transparent.
122-189
:rebuildMarkdown
function logic looks correct.
It carefully replaces only matched sections, preserving untouched content. Implementation and skipping logic for bullet items appear thorough.
This pull request includes updates to the
__tests__/notes.test.ts
andsrc/notes.ts
files to improve the handling and generation of release notes. The main changes involve adding new test cases, modifying release note generation logic, and refactoring the code for better readability and maintainability.Test Improvements:
parseNotes
function and ensure it handles various types of changes and contributors correctly.Code Refactoring:
generateReleaseNotes
function to include a newrebuildMarkdown
function, which reconstructs the markdown content with processed sections while preserving the original structure.collapseSections
function to add collapse tags to sections exceeding the specified item limit, enhancing readability and maintainability.Configuration Changes:
generateReleaseNotes
function to disable grouping of dependencies by default in one of the test cases.Debugging and Logging:
generateReleaseNotes
function to log the structure of sections after processing, aiding in debugging and verification.These changes ensure the release notes are generated accurately and in a well-structured format, improving the overall reliability and maintainability of the codebase.
Summary by CodeRabbit
New Features
Refactor
Tests