Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

affected is broken due to incorrect gitignore handling #27888

Open
1 of 4 tasks
cdaringe opened this issue Sep 12, 2024 · 0 comments
Open
1 of 4 tasks

affected is broken due to incorrect gitignore handling #27888

cdaringe opened this issue Sep 12, 2024 · 0 comments

Comments

@cdaringe
Copy link
Contributor

cdaringe commented Sep 12, 2024

Current Behavior

affected -t build --files=packages/foo/src/index.ts yields no output

Expected Behavior

The above command should yield package foo

GitHub Repo

n/a

Steps to Reproduce

n/a

You can reproduce, but see below conversation. This behavior is traced.

Nx Report

19.7.2

Failure Logs

n/a

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Here's the scoop.

Suppose you have two types of packages:

  • package type foo, e.g. a generic node lib
  • package type bar

The {workspaceRoot}/.gitignore has:

# {workspaceRoot}/.gitignore
src/**

...in it, because 99% of your packages are bars. Imagine that bar packages are all codegen'd, so you don't want to track src. It seemed easier to to put this in the root ignore vs every per-package gitignore.

Now, imagine that packages/foo undoes that root gitignore with:

# {workspaceRoot}/packages/foo/.gitignore
!src/**

Now, try doing affected --files=packages/foo/src/some/modue.ts. Bummer, affected says that foo is not affected!

TLDR: https://github.com/nrwl/nx/blob/b6140d459020847818b738ddc17e52c069657893/packages/nx/src/project-graph/file-utils.ts#L67C12-L67C27 does not consider package gitignores, thus incorrectly computes affected.

Discussion:

  • affected should pick up on project/package level gitignores, or
  • error on their presence, as they lead to surprising behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant