Skip to content

Conversation

ekisu
Copy link
Contributor

@ekisu ekisu commented Sep 17, 2025

Issue # (if applicable)

Closes #9146

Reason for this change

When bundling assets with IgnoreMode.GIT, files that should be included via negation patterns (like !*.html) are incorrectly excluded if they're inside directories that are also re-included by negation patterns. Here's an example - consider the following tree:

- index.html
- app/
    - component.js
    - index.html
    - home.html

If we use a exclude pattern of ['*', '!*.html', '!*/'], the index.html in the root and both HTML files from the app folder should be included - the app folder shouldn't be excluded, due to the !*/ pattern. Right now, only the index.html file in the root folder is included.

Description of changes

Similar to #22002, I've updated the completelyIgnores logic that's used to check if we need to skip a directory tree to include a trailing slash before verifying whether it's an ignored pattern. This makes it properly match directory-specific negation patterns like !*/ by ensuring we're checking directory paths (with trailing slashes) against directory patterns.

I've also updated the logic in fingerprint to check if we're ignoring directories or files, and call completelyIgnores or ignores accordingly.

Describe any new or updated permissions being added

None.

Description of how you validated changes

Added unit tests covering the described scenarios.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@ekisu ekisu requested a review from a team as a code owner September 17, 2025 03:43
@aws-cdk-automation aws-cdk-automation requested a review from a team September 17, 2025 03:43
@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/small Small work item – less than a day of effort p2 labels Sep 17, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@ekisu
Copy link
Contributor Author

ekisu commented Sep 17, 2025

@aws-cdk-automation Clarification Request

How would I go about writing an integration test for functionality in the core package?

@aws-cdk-automation aws-cdk-automation added the pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run label Sep 17, 2025
@mrgrain mrgrain added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Sep 19, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review September 19, 2025 10:19

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@mrgrain mrgrain changed the title fix(core): ignoring files with negated gitignore patterns inside subdirectories fix(core): negated gitignore patterns inside subdirectories are not including matched files Sep 22, 2025
Copy link
Contributor

mergify bot commented Sep 22, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Copy link
Contributor

mergify bot commented Sep 22, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 44781ef into aws:main Sep 22, 2025
19 checks passed
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/small Small work item – less than a day of effort p2 pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run pr-linter/exempt-integ-test The PR linter will not require integ test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[@aws-cdk/assets] docs issue - Negate exclude pattern doesn't work
3 participants