Skip to content

Fix project.toml directory exclusion behavior #2404

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jjbustamante
Copy link
Member

@jjbustamante jjbustamante commented Jun 21, 2025

Summary

Fixes unexpected behavior when excluding directories with trailing slash patterns in project.toml. Previously, patterns like "foo/" would exclude files within the directory but still create empty directory entries in the final image. This change ensures that when users specify exclude = ["foo/"], the directory foo and all its contents are completely excluded from the build process.

Output

Before

When using project.toml with:

[io.buildpacks]
exclude = [
  "foo/"
]

The build would show:

===> BUILDING
.
./foo
./project.toml

The empty foo/ directory was still present during build and in the final image.

After

With the same project.toml configuration, the build now shows:

===> BUILDING
.
./project.toml

The foo/ directory is completely excluded, with no empty directory artifacts.

Documentation

  • Should this change be documented?
    • No
    • Yes (Maybe in the spec?)

Related

Resolves #2402

@jjbustamante jjbustamante requested review from a team as code owners June 21, 2025 17:22
@github-actions github-actions bot added this to the 0.39.0 milestone Jun 21, 2025
@github-actions github-actions bot added the type/enhancement Issue that requests a new feature or improvement. label Jun 21, 2025
@jjbustamante jjbustamante force-pushed the jjbustamante/fix-pack-2402 branch from cdbb47c to 0d61b4c Compare June 21, 2025 17:30
@github-actions github-actions bot added the type/chore Issue that requests non-user facing changes. label Jun 21, 2025
jjbustamante and others added 4 commits June 25, 2025 12:56
This change fixes unexpected behavior when excluding directories with trailing
slash patterns in project.toml. Previously, patterns like "foo/" would exclude
files within the directory but still create empty directory entries in the
final image.

Changes:
- Enhanced getFileFilter() to properly exclude directories when patterns end with "/"
- Modified WriteDirToTar() to skip entire directory trees using filepath.SkipDir
- Fixed isNil() function in testhelpers to properly handle nil function pointers
- Added comprehensive tests for directory exclusion scenarios

The fix ensures that when users specify exclude = ["foo/"] in project.toml,
the directory "foo" and all its contents are completely excluded from the build
process, eliminating the unexpected empty directory artifacts.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Juan Bustamante <[email protected]>
The previous fix was too broad and broke other tests that expected different
nil behavior for interfaces, channels, maps, and slices. This change restricts
the fix to only handle the specific case of nil function pointers while
maintaining compatibility with existing tests.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Juan Bustamante <[email protected]>
- Enhanced getFileFilter to include parent directories when files within them match include patterns
- Fixed compile error in acceptance test framework fmt.Sprint -> fmt.Sprintf
- Added comprehensive test for parent directory inclusion behavior
- Ensures directories like 'media' are included when 'media/mountain.jpg' is in include patterns

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Juan Bustamante <[email protected]>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Juan Bustamante <[email protected]>
@jjbustamante jjbustamante force-pushed the jjbustamante/fix-pack-2402 branch from c62871e to 9862d50 Compare June 25, 2025 18:01
@@ -0,0 +1,153 @@
# CLAUDE.md
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi! Could you move the unrelated changes to a separate PR? :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/chore Issue that requests non-user facing changes. type/enhancement Issue that requests a new feature or improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected project.toml include/exclude behavior
2 participants