Skip to content

Add auto mode based on semver commits - #1720

Open
Kira2K wants to merge 4 commits into
changesets:mainfrom
Kira2K:semver-commits
Open

Kira2K wants to merge 4 commits into
changesets:mainfrom
Kira2K:semver-commits

Conversation

@Kira2K

@Kira2K Kira2K commented Aug 27, 2025

Copy link
Copy Markdown

Auto Mode Feature Implementation

Overview

This PR implements an auto mode feature for Changesets that automatically generates changesets based on conventional commit analysis.

Key Features

  • New --auto flag for changeset add command
  • Integrates with @semantic-release/commit-analyzer using conventionalcommits preset
  • Handles breaking changes detection and scope-based bump logic for monorepos
  • Configurable via maxCommits, preset, and custom analyzer options
  • No breaking changes, full compatibility with existing logic

Technical Implementation

  • packages/cli/src/commands/add/auto-mode.ts - Main auto-mode logic
  • packages/cli/src/commands/add/semanticAnalyzer.ts - Commit analysis integration

Configuration & Usage

Configure via "auto": { "maxCommits": 100, "preset": "conventionalcommits" } in .changeset/config.json. (standart path)
Usage: npx changeset add --auto

Fixes issues

fixes #862
#1504
#1698

@changeset-bot

changeset-bot Bot commented Aug 27, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ee4445b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 15 packages
Name Type
@changesets/cli Minor
@changesets/config Patch
@changesets/types Patch
@changesets/apply-release-plan Patch
@changesets/assemble-release-plan Patch
@changesets/get-release-plan Patch
@changesets/changelog-git Patch
@changesets/changelog-github Patch
@changesets/get-dependents-graph Patch
@changesets/parse Patch
@changesets/pre Patch
@changesets/read Patch
@changesets/release-utils Patch
@changesets/should-skip-package Patch
@changesets/write Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Kira2K Kira2K changed the title Semver commits Add auto mode based on semver commits Aug 27, 2025
@Kira2K

Kira2K commented Aug 27, 2025

Copy link
Copy Markdown
Author

The failing tests and Typecheck are the same as at current state of "main" branch, so it seems to be unrelated to the feature I added

@Kira2K
Kira2K force-pushed the semver-commits branch 3 times, most recently from fc85529 to 52f1228 Compare December 4, 2025 04:57
@codecov

codecov Bot commented Dec 4, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.35294% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.69%. Comparing base (3cb9982) to head (ee4445b).

Files with missing lines Patch % Lines
packages/config/src/index.ts 7.69% 12 Missing ⚠️
packages/cli/src/commands/add/auto-mode.ts 91.39% 8 Missing ⚠️
packages/cli/src/run.ts 0.00% 3 Missing ⚠️
packages/cli/src/commands/add/index.ts 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1720      +/-   ##
==========================================
+ Coverage   81.33%   81.69%   +0.35%     
==========================================
  Files          54       55       +1     
  Lines        2277     2409     +132     
  Branches      684      726      +42     
==========================================
+ Hits         1852     1968     +116     
- Misses        420      436      +16     
  Partials        5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rahul-sharma-uipath

rahul-sharma-uipath commented Dec 5, 2025

Copy link
Copy Markdown

please merge this PR - this would be super helpful :)

await addChangeset(cwd, { auto: true }, mockConfig);

// Verify both packages were processed
expect(mockExecSync).toHaveBeenCalledWith(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think here the comment is not matching this expectation (or at least the expectation is not specific enough). Can it be more specific?

await addChangeset(cwd, { auto: true }, mockConfig);

// Verify the function correctly identified conventional vs non-conventional commits
expect(mockExecSync).toHaveBeenCalledWith(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think here the comment is not matching this expectation (or at least the expectation is not specific enough). Can it be more specific?


// Verify breaking change was detected
expect(mockExecSync).toHaveBeenCalledWith(
"git tag --list --sort=-v:refname",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The same here.

await addChangeset(cwd, { auto: true }, configWithMaxCommits);

// Verify the function respected the maxCommits setting
expect(mockExecSync).toHaveBeenCalledWith(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The same here.


const mockExecSync = execSync as jest.MockedFunction<typeof execSync>;

describe("Auto Mode - Integration Tests", () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why are there two integration tests files for auto mode? Should these files be merged?

await addChangeset(cwd, { auto: true }, mockConfig);

// Verify git commands were called correctly
expect(mockExecSync).toHaveBeenCalled();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should this expectation be more specific, as it was done on the previous test?

await addChangeset(cwd, { auto: true }, mockConfig);

// Verify git commands were called correctly
expect(mockExecSync).toHaveBeenCalled();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The same here.

"description": "Conventional commit preset to use",
"default": "conventionalcommits"
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing the analyzer? Or is it not part of the official configuration?

maxCommits?: number;
/** Conventional commit preset to use (default: "conventionalcommits") */
preset?: string;
/** Custom analyzer function for commit analysis */

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
/** Custom analyzer function for commit analysis */
/** Custom analyzer function for commit analysis (for testing) */

}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should analyzer also be validated? Or is it not part of the official configuration?

@catiaraminhos

Copy link
Copy Markdown

@bluwy Can you also take a look?

@bluwy

bluwy commented Dec 9, 2025

Copy link
Copy Markdown
Member

Sorry, I'm not really interested in the feature request but if other maintainers think otherwise I'm happy to lend a review. At first it felt tedious to me too that changesets didn't rely on conventional commits for changes, but after getting used to it, I much prefer how it doesn't tie changes to git commits and that it encourages better changelogs.

@sbsrnt

sbsrnt commented Jan 3, 2026

Copy link
Copy Markdown

@bluwy counter points from someone who is fairly new to the changesets:

  1. Small hotfixes (1-2 commits) are literally 1:1 of changeset summary and commit messages
  2. For a medium amount of changes (~5 maybe 10 commits at most) I did find that the changesets summary is basically a glorified list of commit messages - you basically copy-paste what you already typed but instead you add dots to make it pretty
  3. You can't really automate dependabot PRs for patch versions (well speaking of which there is How to automate dependabot updates generating a changeset #647 (comment))
  4. Looking at the above points I can't see how this is better than automation

--auto mode from what I looked at is an optional way of creating changesets so by default you will still be encouraged to create better changelogs

Obviously, if you commit every single line of code, your commit messages are only "wip" or you have dozens of commits because you work on a new feature then this mode has little to no value because it will create noise.

I would say a more valid reason not to support this is a maintenance burden.
If this would get merged, then some users will take the feature for granted and expect full support of it from now on.

Personally, I do see a value for this mode for aforementioned points knowing I could simply do pnpm changeset --auto and push changes instead of re-typing the same message.

@PI-Gorbo

Copy link
Copy Markdown

This feature would be fantastic for my current workflow and I am in full support of it - but this voice is coming from a non maintainer (right now).

I enforce conventional commits, and I generally make my changers from my commits + a light summary sometimes.

It would be ideal to have an --auto mode which allows the changset to be inferred from the commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streamline changeset generation with conventional commit support

6 participants