Coder Social home page Coder Social logo

Comments (4)

thdk avatar thdk commented on August 17, 2024

@Badisi if your commit convention allows you to use other types than fix or feat you can configure your nx release command to ignore certain types of commits when the release command needs to determine the next version.

See the documentation here: https://nx.dev/recipes/nx-release/customize-conventional-commit-types

A change to non-projects files can always be affecting other projects. I believe this is a safe approach as it leaves it to the developer to use commit types such as chore or test to mark a commit to be 'hidden' in your changelog and not cause any version bump.

from nx.

Badisi avatar Badisi commented on August 17, 2024

@thdk, I'm using the default commit convention, nothing fancy here.

My real concern is that when using independent mode and projectChangelogs level, changelogs should only be scoped to a project level and not include any workspace changes.

And that's actually what the documentation says:

... they are generated for each project individually and only contain changes for that specific project ...

So in this particular scenario I completely disagree with you when you say that "a change to non-projects files can always be affecting other projects". The idea behind projectChangelogs is purposely to ignore any changes that was made outside of a project scope and only include what was made inside it.

As for commit types such as chore or test, I agree they can help 'hide' a commit but it's just a dirty solution here and does not completely solves the problem. To err is human, and you can't depend on a developer always remembering to use the correct commit types to ensure proper scoping or exclusion within a project.

from nx.

Badisi avatar Badisi commented on August 17, 2024

I also found that there is an inconsistency in the way that commits are filtered for independent projects.

  • When resolving the next semver version, commits are filtered this way:

    /**
    * The relevant commits are those that either:
    * - touch project files which are contained within the list of projects directly
    * - touch non-project files and the commit is not scoped
    */
    return commits.filter((c) =>
    c.affectedFiles.some(
    (f) =>
    filesInReleaseGroup.has(f) ||
    (!c.scope &&
    fileMap.nonProjectFiles.some(
    (nonProjectFile) => nonProjectFile.file === f
    ))
    )
    );

  • When generating changelog, commits are filtered that way:

    const commitsForProject = allCommits.filter((c) =>
    c.affectedFiles.find((f) => f.startsWith(project.data.root))
    );


Even worse, when generating a changelog or github release, if useAutomaticFromRef is not set, commits that will be used for the generation are... ALL commits (cf.getCommits here).

This results in a changelog containing, for one individual project, every changes of every projects and even the workspace.

if (releaseGroup.projectsRelationship === 'independent') {
  ...
  if (!fromRef && useAutomaticFromRef) {
    const firstCommit = await getFirstGitCommit();
    const allCommits = await getCommits(firstCommit, toSHA);
    const commitsForProject = allCommits.filter((c) =>
      c.affectedFiles.find((f) => f.startsWith(project.data.root))
    );
    ...
  }
  ...
  if (!commits) {
    commits = await getCommits(fromRef, toSHA); // <--- here, all commits will be used for the changelog generation
  }
}

from nx.

christophsaile avatar christophsaile commented on August 17, 2024

Hey, I have a similar issue in my project. I am using projectChangelogs but without independent release.
In the index.js of the changelog renderer I did the following changes to fix my issue:

diff --git a/release/changelog-renderer/index.js b/release/changelog-renderer/index.js
index ca7ef3c27ea5c76819a85947a002d952285fd467..390254908990c04bfb5eb73b3dda18570b006302 100644
--- a/release/changelog-renderer/index.js
+++ b/release/changelog-renderer/index.js
@@ -75,8 +75,8 @@ const defaultChangelogRenderer = async ({ projectGraph, changes, releaseVersion,
     }
     else {
         // project level changelog
-        const relevantChanges = changes.filter((c) => c.affectedProjects &&
-            (c.affectedProjects === '*' || c.affectedProjects.includes(project)));
+        // PATCH NOTE: removed the line === '*'. This way root level changes are not included in the project changelog.
+        const relevantChanges = changes.filter((c) => c.affectedProjects && c.affectedProjects.includes(project));
         // Generating for a named project, but that project has no relevant changes in the current set of commits, exit early
         if (relevantChanges.length === 0) {
             if (dependencyBumps?.length) {

from nx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.