bazel-skylib
bazel-skylib copied to clipboard
paths.relativize doesn't support a path not fully under start
The docs for paths.relativize compares itself to os.path.relpath, but the current implementation requires path be fully under start.
In theory it could also work for things that have a common prefix:
paths.relativize("foo/bar/baz", "foo/mumble")could return"../bar/baz"paths.relativize("foo/bar", "foo/mumble/baz")could return"../../bar"paths.relativize("foo/bar/baz", "mumble/grumble")could return"../../foo/bar/baz"
Right now these cases fail, so adding the support shouldn't break anyone. If callers want something fully nested, they could check the result to ensure it doesn't start with ...
Aspect's Bazel library has this: https://docs.aspect.build/rules/aspect_bazel_lib/docs/paths/#relative_file