Make --experimental_repository_hash_file accept paths relative to the workspace
Make the option --experimental_repository_hash_file also accept
paths relative to the workspace, instead of only absolute paths. In this way,
users of resolved files can simply add an entry
build --experimental_repository_hash_file=resolved.bzl
to their .bazelrc file.
@@ -301,11 +301,14 @@ public class BazelRepositoryModule extends BlazeModule {
}
if (!Strings.isNullOrEmpty(repoOptions.repositoryHashFile)) {
+ Path hashFile;
+ if (env.getWorkspace() != null) {
+ hashFile = env.getWorkspace().getRelative(repoOptions.repositoryHashFile);
+ } else {
+ hashFile = filesystem.getPath(repoOptions.repositoryHashFile);
+ }
resolvedFile =
- Optional.of(
- RootedPath.toRootedPath(
- Root.absoluteRoot(filesystem),
- filesystem.getPath(repoOptions.repositoryHashFile)));
+ Optional.of(RootedPath.toRootedPath(Root.absoluteRoot(filesystem), hashFile));
}
if (!Strings.isNullOrEmpty(repoOptions.experimentalResolvedFileInsteadOfWorkspace)) {
