Skip to content

Conversation

lucacome
Copy link
Owner

@lucacome lucacome commented Feb 27, 2025

Closes #302

Summary by CodeRabbit

  • New Features
    • Introduced a new configuration option to optionally remove conventional commit prefixes from dependency update messages. This change provides cleaner and more flexible release notes, with the option disabled by default.
  • Documentation
    • Enhanced input configuration tables for improved clarity and consistency, simplifying the setup process and ensuring that new options are clearly explained.
  • Tests
    • Expanded test coverage for the new configuration option, ensuring proper functionality and handling of various prefix formats in dependency updates.

@github-actions github-actions bot added documentation Improvements or additions to documentation enhancement New feature or request tests labels Feb 27, 2025
@lucacome lucacome force-pushed the feat/conventional-commits branch 2 times, most recently from 68b4928 to bc54e9d Compare February 27, 2025 06:57
Copy link
Contributor

coderabbitai bot commented Feb 27, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes add a new input parameter (remove-conventional-prefixes / removeConventionalPrefixes) across documentation, test suites, and source code. This parameter, defaulting to false, enables optional removal of conventional commit prefixes from dependency updates and pull request titles. Functions and interfaces have been updated to integrate this flag, and relevant tests have been added to verify both enabled and disabled scenarios.

Changes

Files Change Summary
README.md, action.yml Added new input parameter remove-conventional-prefixes with a default of false; updated descriptions and reformatted input tables.
__tests__/notes.test.ts,
__tests__/release.test.ts,
__tests__/version.test.ts
Introduced and integrated the new option removeConventionalPrefixes in test configurations and cases to validate dependency update grouping behaviors.
src/context.ts,
src/notes.ts
Updated the Inputs interface and associated functions to include the new removeConventionalPrefixes flag; modified groupDependencyUpdates to conditionally remove commit prefixes.

Sequence Diagram(s)

sequenceDiagram
    participant Runner as GitHub Action Runner
    participant Context as getInputs (src/context.ts)
    participant Notes as groupDependencyUpdates (src/notes.ts)
    
    Runner->>Context: Provide inputs (including remove-conventional-prefixes)
    Context-->>Runner: Return Inputs object with removeConventionalPrefixes flag
    Runner->>Notes: Call groupDependencyUpdates(sections, {removeConventionalPrefixes})
    alt Flag enabled
        Notes->>Notes: Remove conventional prefixes and format entries
    else Flag disabled
        Notes->>Notes: Process entries without modifications
    end
    Notes-->>Runner: Return processed dependency update entries
Loading

Possibly related PRs

  • Add more data in tests #467: The changes in the main PR, specifically the addition of the remove-conventional-prefixes parameter and its integration into the generateReleaseNotes function, are directly related to the modifications in the __tests__/notes.test.ts file of the retrieved PR, which also involves testing functionality associated with the handling of conventional prefixes.
  • Handle pre-commit deps and more renovate options #482: The changes in the main PR, specifically the addition of the remove-conventional-prefixes parameter and its integration into the groupDependencyUpdates function, are directly related to the modifications in the retrieved PR, which also enhances the groupDependencyUpdates function, indicating a shared focus on improving dependency handling.

Poem

I'm just a rabbit, on a coding spree,
Hopping over configs with great glee.
Conventional prefixes, out they go,
Leaving our commits in a cleaner flow.
With every hop, I cheer our code—yee!
🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93545c8 and 50ea4c2.

⛔ Files ignored due to path filters (4)
  • dist/context.d.ts is excluded by !**/dist/**
  • dist/index.js is excluded by !**/dist/**
  • dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • dist/notes.d.ts is excluded by !**/dist/**
📒 Files selected for processing (7)
  • README.md (1 hunks)
  • __tests__/notes.test.ts (6 hunks)
  • __tests__/release.test.ts (1 hunks)
  • __tests__/version.test.ts (1 hunks)
  • action.yml (1 hunks)
  • src/context.ts (2 hunks)
  • src/notes.ts (9 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

coderabbitai bot commented Feb 27, 2025

✅ Actions performed

Full review triggered.

1 similar comment
Copy link
Contributor

coderabbitai bot commented Feb 27, 2025

✅ Actions performed

Full review triggered.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (4)
__tests__/release.test.ts (1)

151-151: Add a targeted test case for removeConventionalPrefixes.

Currently, removeConventionalPrefixes: false is set here without verifying its effect. To ensure full coverage, consider adding a test that simulates a scenario where the release notes would contain conventional commit prefixes and asserts that they remain intact.

__tests__/notes.test.ts (2)

128-128: Extend test scenarios to confirm prefix retention.

Like the previous instance, this reinforces that the default behavior is to keep conventional prefixes. Consider adding more specialized assertions or input variations to confirm correctness under different conditions.


621-638: Assert the default prefix behavior.

This test complements the previous one by confirming that prefixes remain when removeConventionalPrefixes is disabled. The coverage is solid, but consider also verifying that multiple identical dependencies remain grouped appropriately regardless of prefix presence.

src/notes.ts (1)

344-347: Lock file maintenance prefix condition.

Conditionally injecting the prefix is a clean approach, consistent with the other patterns. If you foresee more specialized behaviors, consider extracting it into a helper function for easier maintenance.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe0839a and bc54e9d.

⛔ Files ignored due to path filters (4)
  • dist/context.d.ts is excluded by !**/dist/**
  • dist/index.js is excluded by !**/dist/**
  • dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • dist/notes.d.ts is excluded by !**/dist/**
📒 Files selected for processing (7)
  • README.md (1 hunks)
  • __tests__/notes.test.ts (4 hunks)
  • __tests__/release.test.ts (1 hunks)
  • __tests__/version.test.ts (1 hunks)
  • action.yml (1 hunks)
  • src/context.ts (2 hunks)
  • src/notes.ts (6 hunks)
🔇 Additional comments (19)
__tests__/version.test.ts (1)

18-18: Change looks good - adds support for the new input parameter

The addition of removeConventionalPrefixes: false to the fakeInputs object is appropriate and maintains consistency with the interface changes in src/context.ts.

action.yml (1)

37-40: Clearly documents the new conventional commit prefixes feature

The new input parameter is well-documented with a clear description and appropriate default value. The placement in the configuration file is logical, following other formatting-related options like group-dependencies.

README.md (1)

40-53: Improved table formatting and documentation of the new feature

The markdown table has been reformatted for better readability, and the new remove-conventional-prefixes parameter is properly documented with consistent formatting. The description clearly explains its purpose in removing conventional prefixes from PR titles.

src/context.ts (2)

16-16: Good addition to the Inputs interface

The new removeConventionalPrefixes property is properly added to the Inputs interface. The naming is consistent with the kebab-case to camelCase conversion pattern used for other input parameters.


42-42: Implementation matches interface and action.yml definition

The getInputs function is properly updated to retrieve the boolean value using core.getBooleanInput, consistent with how other boolean inputs are handled.

__tests__/notes.test.ts (7)

87-87: Well-defined default behavior.

Using removeConventionalPrefixes: false here is consistent with preserving prefixes by default. This aligns with the PR objective of making the prefix removal an opt-in feature.


496-496: Check grouping impact.

This line introduces a second fix entry for the same dependency. Ensure that the downstream grouping logic correctly merges this entry when removeConventionalPrefixes is toggled, especially since it’s a separate PR ID.


505-505: Ensure consistent usage of the options object.

You are explicitly passing { removeConventionalPrefixes: true } here. Verify that calling groupDependencyUpdates in other places leverages the same interface consistently and that the tests cover both true and false scenarios extensively.


509-512: Succinctly verifying merges in test results.

You are checking that multiple PRs for the same dependency are merged into a single line. The logic looks correct. Great job ensuring the test coverage for both DependaBot and Renovate.


597-619: Good coverage for removing conventional commit prefixes.

This test effectively validates the removal of fix(deps):, chore(deps):, etc. from the final grouped entries. The test scenario is thorough, covering multiple prefix cases in a single group.


640-659: Helpful test for verifying group integrity post-prefix removal.

Here, you showcase that removing the prefixes does not compromise accurate grouping for multiple dependencies. The logic and test are well-aligned—nice work.


661-681: Broad coverage for advanced prefix variants.

This test effectively handles multiple advanced prefix forms (ci, build, chore(deps-dev), etc.). The step-by-step grouping is well-validated here.

src/notes.ts (7)

69-71: Conditional grouping logic.

By conditionally invoking groupDependencyUpdates with removeConventionalPrefixes, you allow flexible release note formatting. Confirm that any conditionally updated sections still match the user’s natural reading expectation.


301-306: Enhanced groupDependencyUpdates signature.

Accepting the new options object with removeConventionalPrefixes increases this function’s extensibility. Good approach for possible future additions.


308-316: Well-structured prefix handling.

Defining the conventionalPrefixRegex and optionalPrefixPattern ensures the prefix removal logic is central and consistent. Great job maintaining readability.


393-393: Prefix state in grouping.

Storing prefix in the grouping logic is a subtle but crucial step toward re-applying the original text if removeConventionalPrefixes is false. This maintains consistent representation of each entry.


401-412: Robust prefix removal before grouping.

This ensures the item is updated in-place, guaranteeing consistent grouping keys. Verify that no unintended transformations occur for lines lacking a recognized prefix.


426-431: Conditional prefix extraction.

When removeConventionalPrefixes is disabled, the logic elegantly extracts the prefix from the matched line. This design fosters clarity between the with/without prefix flows.


650-657: Helper for capitalizing first word.

This utility is straightforward and exactly what's needed to tidy up the first word after prefix removal. Thoroughly tested in the new test cases—nicely done.

@lucacome lucacome force-pushed the feat/conventional-commits branch 3 times, most recently from 5b29ef6 to 93545c8 Compare February 28, 2025 04:38
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (4)
__tests__/notes.test.ts (4)

87-87: Consider adding a test case with removeConventionalPrefixes: true.

Here, you set the default to false, which is consistent with your summaries. Nonetheless, testing at least one scenario with true in this same suite ensures robust coverage without relying solely on separate tests.


128-128: Duplicated default configuration.

Same observation—you're setting removeConventionalPrefixes: false again. Ensure the suite also covers scenarios where removeConventionalPrefixes is true (or confirm they’re tested in other blocks).


597-624: Test coverage for mixed prefix types is comprehensive.

Your test accurately checks prefix precedence between older and newer versions. Consider adding a corner case where the dependency name differs slightly (e.g., capitalized vs. lowercase) to ensure consistent grouping under all naming variations.


646-753: Extensive test suite for removeConventionalPrefixes.

These tests thoroughly cover various prefix cases, empties, and capitalized words. Minor suggestion: adjust the test name “capitalized first word after removing prefix” to a more consistent style like “should capitalize the first word after removing prefix.”

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b29ef6 and 93545c8.

⛔ Files ignored due to path filters (4)
  • dist/context.d.ts is excluded by !**/dist/**
  • dist/index.js is excluded by !**/dist/**
  • dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • dist/notes.d.ts is excluded by !**/dist/**
📒 Files selected for processing (7)
  • README.md (1 hunks)
  • __tests__/notes.test.ts (6 hunks)
  • __tests__/release.test.ts (1 hunks)
  • __tests__/version.test.ts (1 hunks)
  • action.yml (1 hunks)
  • src/context.ts (2 hunks)
  • src/notes.ts (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • tests/version.test.ts
  • action.yml
  • tests/release.test.ts
  • src/context.ts
  • README.md
  • src/notes.ts
🔇 Additional comments (4)
__tests__/notes.test.ts (4)

2-2: Addition of removeConventionalPrefixes import looks solid.

You're now importing removeConventionalPrefixes, aligning with your new feature tests. This is a straightforward and correct addition.


496-496: Good job including a lower version prefix example.

This test entry helps verify proper grouping logic when multiple versions exist for the same dependency. No further changes needed.


509-509: Correct grouping outcome.

The merged PR references show that the logic for combining repeated dependencies is functioning as intended. Nice work.


626-644: Robust validation of “special format” commit prefixes.

The scenario coverage for unconventional prefixes (e.g., refactor(deps) or perf(deps)) looks good. The test ensures the output remains unchanged when removeConventionalPrefixes is false.

@lucacome lucacome force-pushed the feat/conventional-commits branch from 93545c8 to 50ea4c2 Compare February 28, 2025 06:57
@lucacome lucacome enabled auto-merge (squash) February 28, 2025 06:57
@lucacome lucacome merged commit 54ef61a into main Feb 28, 2025
12 of 14 checks passed
@lucacome lucacome deleted the feat/conventional-commits branch February 28, 2025 06:57
@lucacome lucacome requested a review from Copilot February 28, 2025 07:11
Copy link

@Copilot Copilot AI left a 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 adds support for conventional commits by introducing a new configuration option to remove conventional commit prefixes from dependency update messages. The key changes include updating test cases, modifying the main release note generation logic in src/notes.ts to support prefix removal, and adding the corresponding configuration in both the action and documentation.

Reviewed Changes

File Description
tests/notes.test.ts Updated tests to verify behavior when removing conventional commit prefixes.
src/notes.ts Added support for removing conventional commit prefixes and updated dependency grouping logic.
src/context.ts Extended the Inputs interface to include the new removeConventionalPrefixes option.
action.yml Added a new input for remove-conventional-prefixes with default set to false.
README.md Updated documentation to describe the new remove-conventional-prefixes input.
tests/version.test.ts Updated tests to pass the new removeConventionalPrefixes input.
tests/release.test.ts Updated tests to pass the new removeConventionalPrefixes input.

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

* @param regex - The regex pattern to use for matching the prefix.
* @returns The extracted prefix including scope and colon+space, or an empty string if none found.
*/
function getPrefix(str: string, regex: RegExp): string {
Copy link
Preview

Copilot AI Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Ensure that getPrefix correctly handles cases with extra whitespace between the bullet point and the conventional prefix. Consider using a more robust trimming strategy rather than relying solely on substring(2).

Copilot uses AI. Check for mistakes.

@coderabbitai coderabbitai bot mentioned this pull request Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support removing prefix from conventional commits
1 participant