diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java index 2e515fc7e46164..02f013fa014eb9 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java @@ -350,12 +350,12 @@ public ModuleOverride convert(String input) throws OptionsParsingException { OptionsUtils.AbsolutePathFragmentConverter absolutePathFragmentConverter = new OptionsUtils.AbsolutePathFragmentConverter(); try { - var unused = absolutePathFragmentConverter.convert(pieces[1]); + var path = absolutePathFragmentConverter.convert(pieces[1]); + return ModuleOverride.create(pieces[0], path.toString()); } catch (OptionsParsingException e) { throw new OptionsParsingException( "Module override directory must be an absolute path", input, e); } - return ModuleOverride.create(pieces[0], pieces[1]); } @Override diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptionsTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptionsTest.java index 478a09937f72c4..5de4cc8b5a8ec5 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptionsTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptionsTest.java @@ -17,6 +17,8 @@ import static com.google.common.base.StandardSystemProperty.USER_HOME; import static com.google.common.truth.Truth.assertThat; +import com.google.devtools.build.lib.bazel.repository.RepositoryOptions.ModuleOverride; +import com.google.devtools.build.lib.bazel.repository.RepositoryOptions.ModuleOverrideConverter; import com.google.devtools.build.lib.bazel.repository.RepositoryOptions.RepositoryOverride; import com.google.devtools.build.lib.bazel.repository.RepositoryOptions.RepositoryOverrideConverter; import com.google.devtools.build.lib.cmdline.RepositoryName; @@ -60,6 +62,14 @@ public void testOverridePathWithTilde() throws Exception { assertThat(actual.path()).isEqualTo(PathFragment.create(USER_HOME.value() + "/bar")); } + @Test + public void testModuleOverridePathWithTilde() throws Exception { + var converter = new ModuleOverrideConverter(); + ModuleOverride actual = converter.convert("foo=~/bar"); + assertThat(PathFragment.create(actual.path())) + .isEqualTo(PathFragment.create(USER_HOME.value() + "/bar")); + } + @Test public void testInvalidOverride() throws Exception { expectedException.expect(OptionsParsingException.class);