Skip to content

Commit

Permalink
Remove "get" from field names in BzlmodFlagsAndEnvVars class
Browse files Browse the repository at this point in the history
Disable Html escaping for better format

To make things more clear in the lockfile

PiperOrigin-RevId: 521440311
Change-Id: Ieab404109649f8612692a6472221c59c0bd9d655
  • Loading branch information
SalmaSamy authored and copybara-github committed Apr 3, 2023
1 parent 83c954d commit aa2407f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ public static BzlmodFlagsAndEnvVars create(
}

/** Registries provided via command line */
public abstract ImmutableList<String> getCmdRegistries();
public abstract ImmutableList<String> cmdRegistries();

/** ModulesOverride provided via command line */
public abstract ImmutableMap<String, String> getCmdModuleOverrides();
public abstract ImmutableMap<String, String> cmdModuleOverrides();

/** Allowed yanked version in the dependency graph */
public abstract ImmutableList<String> getAllowedYankedVersions();
public abstract ImmutableList<String> allowedYankedVersions();

/** Allowed yanked version in the dependency graph from environment variables */
public abstract String getEnvVarAllowedYankedVersions();
public abstract String envVarAllowedYankedVersions();

/** Whether to ignore things declared as dev dependencies or not */
public abstract boolean ignoreDevDependency();

/** Error level of direct dependencies check */
public abstract String getDirectDependenciesMode();
public abstract String directDependenciesMode();

/** Error level of bazel compatability check */
public abstract String getCompatibilityMode();
public abstract String compatibilityMode();
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public Registry read(JsonReader jsonReader) throws IOException {
private static final GsonBuilder adapterGson =
new GsonBuilder()
.setPrettyPrinting()
.disableHtmlEscaping()
.registerTypeAdapterFactory(GenerateTypeAdapter.FACTORY)
.registerTypeAdapterFactory(DICT)
.registerTypeAdapterFactory(IMMUTABLE_MAP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ public void simpleModule() throws Exception {

@Test
public void simpleModuleWithFlags() throws Exception {
// Test having --ovseride_module, --ignore_dev_dependency, --check_bazel_compatibility &
// --check_direct_dependencies
// Test having --override_module, --ignore_dev_dependency, --check_bazel_compatibility
// --check_direct_dependencies & --registry
scratch.file(
rootDirectory.getRelative("MODULE.bazel").getPathString(),
"module(name='my_root', version='1.0')");
Expand All @@ -218,10 +218,12 @@ public void simpleModuleWithFlags() throws Exception {

ImmutableList<String> yankedVersions = ImmutableList.of("2.4", "2.3");
LocalPathOverride override = LocalPathOverride.create("override_path");
ImmutableList<String> registries = ImmutableList.of("registry1", "registry2");
ImmutableMap<String, String> moduleOverride = ImmutableMap.of("my_dep_1", override.getPath());

ModuleFileFunction.IGNORE_DEV_DEPS.set(differencer, true);
ModuleFileFunction.REGISTRIES.set(differencer, registries);
ModuleFileFunction.MODULE_OVERRIDES.set(differencer, ImmutableMap.of("my_dep_1", override));

BazelModuleResolutionFunction.ALLOWED_YANKED_VERSIONS.set(differencer, yankedVersions);
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES.set(
differencer, CheckDirectDepsMode.ERROR);
Expand All @@ -243,10 +245,12 @@ public void simpleModuleWithFlags() throws Exception {
BazelLockFileValue value = result.get(BazelLockFileValue.KEY);
assertThat(value.getModuleDepGraph()).isEqualTo(depGraph);
assertThat(value.getFlags().ignoreDevDependency()).isTrue();
assertThat(value.getFlags().getAllowedYankedVersions()).isEqualTo(yankedVersions);
assertThat(value.getFlags().getDirectDependenciesMode())
assertThat(value.getFlags().cmdRegistries()).isEqualTo(registries);
assertThat(value.getFlags().cmdModuleOverrides()).isEqualTo(moduleOverride);
assertThat(value.getFlags().allowedYankedVersions()).isEqualTo(yankedVersions);
assertThat(value.getFlags().directDependenciesMode())
.isEqualTo(CheckDirectDepsMode.ERROR.toString());
assertThat(value.getFlags().getCompatibilityMode())
assertThat(value.getFlags().compatibilityMode())
.isEqualTo(BazelCompatibilityMode.ERROR.toString());
}

Expand Down

0 comments on commit aa2407f

Please sign in to comment.