rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] Using --bump-type with rush change doesn't accept the passed argument in a repo with version policies

Open andreidobrinski opened this issue 1 year ago • 2 comments
trafficstars

Summary

I'm using Rush inside of a monorepo with packages that use version policies and lockstepped versions.

The rush change docs indicate that it's possible to pass a --bump-type with a --bulk flag but this doesn't work.

Any argument to --bump-type will result in a type: "none" as part of the changefile, if the repo uses version policies.

Repro steps

  1. Have a monorepo that uses version policies and lockstepped versions
  2. Make any change to a file
  3. Run the rush change command using rush change --bulk --bump-type patch --message hello-test

Expected result:

The resulting changefile will have a type: "patch"

Actual result:

The resulting changefile has a type: "none".

The issue is reproducible in the case of multiple changefiles and occurs will all other bump types.

Details

There is some undocumented behaviour inside of libraries > rush-lib > src > cli > actions > ChangeAction.ts. See line 555:

// No need to ask for bump types if project is lockstep versioned with an explicit nextBump
if (lockStepPolicy.nextBump !== undefined) {
  bumpOptions = {};
}

This suggests that if the lockstep policy has a nextBump then we can ignore the passed in argument to the rush change command. The nextBump field is required for all repos with version policies, which basically means that the --bump-type feature in rush change will never work in those cases.

For what it's worth, my workflow has been to manually change the type to the value that it's supposed to be. Then I manually adjust the nextBump based on the highest value type from the changefiles prior to each release.

My preference would be to remove the code above and allow users to pass a rush change bump-type with the CLI.

If that's not possible because the behaviour is necessary then I would suggest an update to the rush change docs around the condition(s) that --bump-type would not be expected to work.

Thanks for maintaining this repo and all that you do! Hope this helps and let me know if you have any questions.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? 5.122.1
rushVersion from rush.json? 5.129.7
useWorkspaces from rush.json? n/a
Operating system? Mac
Would you consider contributing a PR? Yes
Node.js version (node -v)? 18.16.0

andreidobrinski avatar Jul 30 '24 20:07 andreidobrinski