Skip to content

Commit

Permalink
flip --incompatible_remap_main_repo
Browse files Browse the repository at this point in the history
Make remapping the main repository the default.

RELNOTES: Both ways of addressing the main repository, by its name and by '@' are
    now considered referring to the same repository.

Change-Id: I659e4713c57715d7acf4ce57aa1973a9529d443d
PiperOrigin-RevId: 280155697
  • Loading branch information
aehlig authored and copybara-github committed Nov 13, 2019
1 parent 6dd4ad4 commit 81b57d6
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl

@Option(
name = "incompatible_remap_main_repo",
defaultValue = "false",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = OptionEffectTag.LOADING_AND_ANALYSIS,
metadataTags = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public static Builder builderWithDefaults() {
.incompatibleNoRuleOutputsParam(false)
.incompatibleNoSupportToolsInActionInputs(true)
.incompatibleNoTargetOutputGroup(true)
.incompatibleRemapMainRepo(false)
.incompatibleRemapMainRepo(true)
.incompatibleRemoveNativeMavenJar(false)
.incompatibleRunShellCommandString(false)
.incompatibleRestrictNamedParams(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ public void testImplicitMainRepoRename() throws Exception {

@Test
public void testNoImplicitMainRepoRenameWithoutFlag() throws Exception {
helper.setSkylarkSemantics("--noincompatible_remap_main_repo");
helper.parse("workspace(name = 'foo')");
RepositoryName foo = RepositoryName.create("@foo");
assertThat(helper.getPackage().getRepositoryMapping(RepositoryName.create("@")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ public void testSimpleMapping() throws Exception {
.hasEntryThat(skyKey)
.isEqualTo(
RepositoryMappingValue.withMapping(
ImmutableMap.of(RepositoryName.create("@a"), RepositoryName.create("@b"))));
ImmutableMap.of(
RepositoryName.create("@a"),
RepositoryName.create("@b"),
RepositoryName.create("@good"),
RepositoryName.create("@"))));
}

@Test
Expand All @@ -93,12 +97,20 @@ public void testMultipleRepositoriesWithMapping() throws Exception {
.hasEntryThat(skyKey1)
.isEqualTo(
RepositoryMappingValue.withMapping(
ImmutableMap.of(RepositoryName.create("@a"), RepositoryName.create("@b"))));
ImmutableMap.of(
RepositoryName.create("@a"),
RepositoryName.create("@b"),
RepositoryName.create("@good"),
RepositoryName.create("@"))));
assertThatEvaluationResult(eval(skyKey2))
.hasEntryThat(skyKey2)
.isEqualTo(
RepositoryMappingValue.withMapping(
ImmutableMap.of(RepositoryName.create("@x"), RepositoryName.create("@y"))));
ImmutableMap.of(
RepositoryName.create("@x"),
RepositoryName.create("@y"),
RepositoryName.create("@good"),
RepositoryName.create("@"))));
}

@Test
Expand All @@ -119,8 +131,12 @@ public void testRepositoryWithMultipleMappings() throws Exception {
.isEqualTo(
RepositoryMappingValue.withMapping(
ImmutableMap.of(
RepositoryName.create("@a"), RepositoryName.create("@b"),
RepositoryName.create("@x"), RepositoryName.create("@y"))));
RepositoryName.create("@a"),
RepositoryName.create("@b"),
RepositoryName.create("@x"),
RepositoryName.create("@y"),
RepositoryName.create("@good"),
RepositoryName.create("@"))));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,19 @@ public void testRepositoryMappingInChunks() throws Exception {
RepositoryName b = RepositoryName.create("@b");
RepositoryName x = RepositoryName.create("@x");
RepositoryName y = RepositoryName.create("@y");
RepositoryName good = RepositoryName.create("@good");
RepositoryName main = RepositoryName.create("@");

SkyKey key0 = WorkspaceFileValue.key(workspace, 0);
EvaluationResult<WorkspaceFileValue> result0 = eval(key0);
WorkspaceFileValue value0 = result0.get(key0);
assertThat(value0.getRepositoryMapping()).containsEntry(a, ImmutableMap.of(x, y));
assertThat(value0.getRepositoryMapping()).containsEntry(a, ImmutableMap.of(x, y, good, main));

SkyKey key1 = WorkspaceFileValue.key(workspace, 1);
EvaluationResult<WorkspaceFileValue> result1 = eval(key1);
WorkspaceFileValue value1 = result1.get(key1);
assertThat(value1.getRepositoryMapping()).containsEntry(a, ImmutableMap.of(x, y));
assertThat(value1.getRepositoryMapping()).containsEntry(b, ImmutableMap.of(x, y));
assertThat(value1.getRepositoryMapping()).containsEntry(a, ImmutableMap.of(x, y, good, main));
assertThat(value1.getRepositoryMapping()).containsEntry(b, ImmutableMap.of(x, y, good, main));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function test_set_flag_with_workspace_name() {

write_build_setting_bzl "@${WORKSPACE_NAME}"

bazel build //$pkg:my_drink --@"${WORKSPACE_NAME}"//$pkg:type="coffee" \
bazel build //$pkg:my_drink --@//$pkg:type="coffee" \
--experimental_build_setting_api > output 2>"$TEST_log" \
|| fail "Expected success"

Expand Down

0 comments on commit 81b57d6

Please sign in to comment.