-
Notifications
You must be signed in to change notification settings - Fork 209
feat(pkg_files): preserve external package paths by default #1004
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
base: main
Are you sure you want to change the base?
feat(pkg_files): preserve external package paths by default #1004
Conversation
ce924b0 to
7c12bd3
Compare
cgrindel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. It looks like there is a pre-commit failure. Please ping us when it is addressed.
a57cbf2 to
4a5fabb
Compare
Indeed, I saw https://github.com/bazelbuild/rules_pkg/actions/runs/21136051279/job/61362936971#step:3:156 Done. I think the reason why I had to add a docstring to |
4a5fabb to
d4de47b
Compare
|
Had to document |
|
@aiuto Do you want to review before we merge? |
|
I don't understand the behavior diff for the same workspace, inter package thing. |
c9b8282 to
b64bcc8
Compare
I've done my best to exemplify the change with further tests and added the following note to the commit message/PR description:
|
When no explicit `strip_prefix` is specified, `pkg_files` now automatically
preserves package-relative paths for cross-package and cross-repository
references.
This eliminates the need for manual `strip_prefix` configurations in these
common scenarios.
**Cross-repository example:**
`@external//pkg` → `@//tests:my_files` (contains `tests/testdata/file.txt`)
| `strip_prefix` | Result |
|-----------------------------------|---------------------|
| `strip_prefix.from_root("tests")` | `testdata/file.txt` |
| `strip_prefix.from_pkg()` | `testdata/file.txt` |
| `None` (earlier default behavior) | `file.txt` |
| `None` (new default behavior) | testdata/file.txt` |
**Cross-package example:**
`//pkg_a` → `//pkg_b:my_files` (contains `pkg_b/subdir/file.txt`)
| `strip_prefix` | Result |
|-----------------------------------|-------------------|
| `strip_prefix.from_root("pkg_b")` | `subdir/file.txt` |
| `strip_prefix.from_pkg()` | `subdir/file.txt` |
| `None` (earlier default behavior) | `file.txt` |
| `None` (new default behavior) | `subdir/file.txt` |
Backward compatibility: since direct cross-package target references now
preserve package paths instead of basename only, referencing files in a
local `filegroup` aggregating cross-package files would bring back
basename-only paths.
b64bcc8 to
8bbb77d
Compare
When no explicit
strip_prefixis specified,pkg_filesnow automatically preserves package-relative paths for cross-package and cross-repository references.This eliminates the need for manual
strip_prefixconfigurations in these common scenarios.Cross-repository example:
@external//pkg→@//tests:my_files(containstests/testdata/file.txt)strip_prefixstrip_prefix.from_root("tests")testdata/file.txtstrip_prefix.from_pkg()testdata/file.txtNone(earlier default behavior)file.txtNone(new default behavior)testdata/file.txtCross-package example:
//pkg_a→//pkg_b:my_files(containspkg_b/subdir/file.txt)strip_prefixstrip_prefix.from_root("pkg_b")subdir/file.txtstrip_prefix.from_pkg()subdir/file.txtNone(earlier default behavior)file.txtNone(new default behavior)subdir/file.txtBackward compatibility: since direct cross-package target references now preserve package paths instead of basename only, referencing files in a local
filegroupaggregating cross-package files would bring back basename-only paths.