nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.51k stars 2.34k forks source link

nx release version ignore changes to a package when the associated commit comes from the github "squash and merge" command #26241

Open Bare1337 opened 4 months ago

Bare1337 commented 4 months ago

Current Behavior

When multiple changes are made to a package and are added to the base branch through the "squash and merge" option from github at merge time, launching nx release version on the base branch lead to: {packageName} 🚫 No changes were detected using git history and the conventional commits standard. {packageName} 🚫 Skipping versioning "{packageName}" as no changes were detected.

though my commit is respecting the conventional commits standard and directly affect the package.

Expected Behavior

A commit which respect the conventional commits standard and affect my package should be properly interpreted by nx release version and lead to a correct version compute, whether or not it has been squashed with the github ui command.

GitHub Repo

No response

Steps to Reproduce

1.Create a package in an nx workspace and commit your changes => git commit -m "feat: introduce my package" 2.Create a dummy file inside the created package and commit your changes => git commit -m "feat: new package feat" 3.Create a pull request against the base branch from your current branch and merge using the option "squash and merge" from github UI.

  1. Launch nx release version command from the base branch containing the commit squashed by github.

Nx Report

Node   : 20.9.0
OS     : win32-x64
pnpm   : 8.15.1

nx                 : 18.3.5
@nx/js             : 18.3.5
@nx/jest           : 18.3.5
@nx/linter         : 18.3.5
@nx/eslint         : 18.3.5
@nx/workspace      : 18.3.5
@nx/angular        : 18.3.5
@nx/cypress        : 18.3.5
@nx/devkit         : 18.3.5
@nx/eslint-plugin  : 18.3.5
@nrwl/tao          : 18.3.5
@nx/web            : 18.3.5
@nx/webpack        : 18.3.5
typescript         : 5.4.5

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

The issue comes from a conflict between the separator "----" used by github to delimit the squashed commit messages and the separator used there https://github.com/nrwl/nx/blob/7088b09f472bb767d386df73ca0534e09386d7db/packages/nx/src/command-line/release/utils/git.ts#L129 and there https://github.com/nrwl/nx/blob/7088b09f472bb767d386df73ca0534e09386d7db/packages/nx/src/command-line/release/utils/git.ts#L134

In case of a commit squashed from github here is a result example of the prettify log command:

----
feat: my feat|{hash}|{author}|{email}
* feat: add lib

* feat: new feat for my lib

* fix: fix prettier and linter issues

---------

Co-authored-by: {authorName}

M       .eslintignore
M       .eslintrc.json
A       .github/workflows/main.yml

Because of that format, the split('----') discard changed files completely and nx release version is no longer able to determine if the commit affect any library.

As it seems tough to completely avoid that since people can as well edit the commit format from the UI, we could at least use a different separator or maybe compute a unique separator on the fly.

I'am willing to submit a PR if necessary.

NachoVazquez commented 3 months ago

It seems this is what I'm experiencing as well.

loliver commented 1 week ago

I'm seeing this behaviour as well, my concern is that there's nowhere within the squash-commit message that it specifies which files included in the PR were a part of which commit. Thus making it difficult for nx release to determine which packages should get which level of semver applied to them.