Skip to content

Fix handling of group disallowedChangeTypes with dependent bumps - #1238

Draft
Elizabeth Craig (ecraig12345) wants to merge 1 commit into
mainfrom
ecraig/related-change
Draft

Fix handling of group disallowedChangeTypes with dependent bumps#1238
Elizabeth Craig (ecraig12345) wants to merge 1 commit into
mainfrom
ecraig/related-change

Conversation

@ecraig12345

@ecraig12345 Elizabeth Craig (ecraig12345) commented May 6, 2026

Copy link
Copy Markdown
Member

Fix handling of group disallowedChangeTypes in dependent bumps (bumpInMemory and updateRelatedChangeType).

This should be non-breaking, but this bumping code is the most complex part of beachball and has a higher risk of unexpected side effects, so it's only going in v3. Though from tests, this change didn't cause any failures, and it makes a couple disabled tests pass that didn't before.

Changes:

  • Only call updateRelatedChangeType if bumpDeps is enabled. (Bumping of groups without bumpDeps is handled in bumpInMemory pass 2.)
  • TODO...

Fixes #1092

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Beachball’s bump calculation to correctly apply group-level disallowedChangeTypes during dependent bump propagation, and to only run the dependent-bump traversal when bumpDeps is enabled.

Changes:

  • Restrict updateRelatedChangeType execution to bumpDeps: true and pass a cached packageToGroup mapping for faster group lookup.
  • Update dependent-bump traversal to propagate through groups while applying repo/group/package disallowedChangeTypes.
  • Extend/adjust unit tests to cover group bumping behavior and group disallowedChangeTypes.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/beachball/src/bump/updateRelatedChangeType.ts Reworks the dependent bump traversal, adds group-aware handling and cached group lookup.
packages/beachball/src/bump/bumpInMemory.ts Only invokes dependent traversal when bumpDeps is enabled; builds packageToGroup cache during group initialization.
packages/beachball/src/tests/bump/updateRelatedChangeType.test.ts Updates the helper/setup and adds coverage for group propagation and group disallowedChangeTypes.
change/change-e5e83f54-1a36-4545-9dcc-ee8af7201e1e.json Adds the change file entry documenting this fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/beachball/src/bump/updateRelatedChangeType.ts
Comment thread packages/beachball/src/bump/updateRelatedChangeType.ts
Comment thread packages/beachball/src/bump/updateRelatedChangeType.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (3)

packages/beachball/src/bump/updateRelatedChangeType.ts:98

  • The deduplication key records the incoming dependentChangeType, but the queued item carries newType. When a group downgrades minor to preminor, this makes downstream behavior depend on graph shape: if a second member independently depends on the root, its existing #minor entry wins and its dependents receive minor; otherwise group expansion queues it with preminor and its dependents receive preminor. Use the same propagated type in the key and payload, with a regression test covering both graph shapes.
          const key: SeenKey = `${packageNameInGroup}#${dependentChangeType}`;
          if (!seen.has(key)) {
            seen.add(key);
            queue.push({ subjectPackage: packageNameInGroup, dependentChangeType: newType });

packages/beachball/src/bump/updateRelatedChangeType.ts:92

  • The group expansion is nested under the non-root guard, so a direct change in a group never traverses dependents of sibling members. For example, with grouped foo/bar, a patch change to foo with dependentChangeType: 'minor', and an app depending on bar, pass 2 bumps bar but this traversal never reaches the app despite bumpDeps: true. Preserve the intended behavior of not re-bumping the siblings, but seed dependent traversal from every member of the initially changed package's group (and add this variant to the new root-group test).
      // If this package is in a group, enqueue other packages in the group.
      // (Use an extra set tracking groups to avoid iterating over all member packages.)
      const groupKey = groupName ? (`${groupName}#${dependentChangeType}` as const) : undefined;
      if (group && groupKey && !seenGroups.has(groupKey)) {

packages/beachball/src/bump/updateRelatedChangeType.ts:81

  • This still does not produce the result reported in #1092. In that issue's exact case (dependentChangeType: 'major' and group disallowedChangeTypes: ['major']), getMaxChangeType steps down to premajor, while the issue expects minor; the added test changes the inputs to minor with both major and minor disallowed, so it misses the reported regression. Please cover the issue's exact fixture and ensure a disallowed stable major falls back to the expected stable type before marking #1092 fixed.
      const newType = (calculatedChangeTypes[subjectPackage] = getMaxChangeType(
        [oldType, dependentChangeType],
        // Group disallowedChangeTypes take precedence (actually validation verifies both can't be set)
        // TODO: it's probably better to just save the disallowedChangeTypes with each grouped package during setup?
        group?.disallowedChangeTypes === null
          ? null
          : group?.disallowedChangeTypes ||
              getPackageOption('disallowedChangeTypes', packageInfos[subjectPackage], params.options)

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.

Improve group disallowedChangeTypes handling

2 participants