Repository navigation
nx release: an option to read the commit range with git log --first-parent
#37782
clement-loridan
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Description
Add an option, for example
release.git.firstParent: true, so thatnx releasereads the commits of a release withgit log --first-parent <from>..<to>instead ofgit log <from>..<to>. It would apply to the changelog entry and to the semver bump that conventional commits compute, which both go throughgetGitDiff.Motivation
A common branching model has a dev line (
next, prereleasesx.y.z-next.N) and a stable line (main, hotfixes). A hotfix is released frommain, thenmainis merged intonextwith a merge commit, so thatnextkeeps every published fix.Today the changelog for
v1.1.0-next.1is built fromgit log v1.1.0-next.0..HEAD. That range follows the second parent ofM, so it containsXandR:Xis listed again, althoughv1.0.1already shipped it;Rof the other line is listed too;Xalso counts towards the bump of the prerelease.With
--first-parent, the range contains onlyA,MandB.Mis not a conventional commit, so nx already skips it. When the dev line takes squash merges only, the first-parent history is exactly one commit per pull request, which is what the changelog should list.Suggested implementation
In
packages/nx/src/command-line/release/utils/git.ts,getGitDiffpushes'--first-parent'into itsgit logarguments when the option is on. The default stays off, so nothing changes for existing workspaces.We apply this as a one-line
pnpm patchon nx 23.1.0 today. On our real tags, it removes the forward-ported hotfix from the prerelease entry and leaves the stable entry unchanged.Alternatives
I'd be willing to open the pull request.
All reactions