use of com.google.copybara.config.SkylarkParser.ConfigWithDependencies in project copybara by google.
the class InfoCmd method run.
@Override
public ExitCode run(CommandEnv commandEnv) throws ValidationException, IOException, RepoException {
ConfigFileArgs configFileArgs = commandEnv.parseConfigFileArgs(this, /*useSourceRef*/
false);
Console console = commandEnv.getOptions().get(GeneralOptions.class).console();
ConfigWithDependencies config = configLoaderProvider.newLoader(configFileArgs.getConfigPath(), configFileArgs.getSourceRef()).loadWithDependencies(console);
if (commandEnv.getOptions().get(GeneralOptions.class).infoListOnly) {
listMigrations(commandEnv, config.getConfig());
return ExitCode.SUCCESS;
}
if (configFileArgs.hasWorkflowName()) {
ImmutableMap<String, String> context = contextProvider.getContext(config, configFileArgs, configLoaderProvider, commandEnv.getOptions(), console);
infoWithFailureHandling(commandEnv.getOptions(), config.getConfig(), configFileArgs.getWorkflowName(), context);
} else {
showAllMigrations(commandEnv, config.getConfig());
}
return ExitCode.SUCCESS;
}
use of com.google.copybara.config.SkylarkParser.ConfigWithDependencies in project copybara by google.
the class InfoTest method testInfoAvailableToMigrate.
@Test
public void testInfoAvailableToMigrate() throws Exception {
info = new InfoCmd((configPath, sourceRef) -> new ConfigLoader(skylark.createModuleSet(), skylark.createConfigFile("copy.bara.sky", configInfo), optionsBuilder.general.getStarlarkMode()) {
@Override
public Config load(Console console) {
return config;
}
@Override
public ConfigWithDependencies loadWithDependencies(Console console) {
return configWithDeps;
}
}, getFakeContextProvider());
MigrationReference<DummyRevision> workflow = MigrationReference.create("workflow", new DummyRevision("1111"), ImmutableList.of(newChange("2222", "First change", ZonedDateTime.ofInstant(Instant.ofEpochSecond(1541631979), ZoneId.of("-08:00"))), newChange("3333", "Second change", ZonedDateTime.ofInstant(Instant.ofEpochSecond(1541639979), ZoneId.of("-08:00")))));
Info<?> mockedInfo = Info.create(dummyOriginDescription, dummyDestinationDescription, ImmutableList.of(workflow));
Mockito.<Info<? extends Revision>>when(migration.getInfo()).thenReturn(mockedInfo);
// Copybara copybara = new Copybara(new ConfigValidator() {}, migration -> {});
// copybara.info(optionsBuilder.build(), config, "workflow");
info.run(new CommandEnv(temp, optionsBuilder.build(), ImmutableList.of("copy.bara.sky", "workflow")));
assertThat(eventMonitor.infoFinishedEvent).isNotNull();
assertThat(eventMonitor.infoFinishedEvent.getInfo()).isEqualTo(mockedInfo);
console.assertThat().onceInLog(MessageType.INFO, ".*last_migrated 1111 - last_available 3333.*").onceInLog(MessageType.INFO, ".*Date.*Revision.*Description.*Author.*").onceInLog(MessageType.INFO, ".*2018-11-07 15:06:19.*2222.*First change.*Foo <Bar>.*").onceInLog(MessageType.INFO, ".*2018-11-07 17:19:39.*3333.*Second change.*Foo <Bar>.*");
}
use of com.google.copybara.config.SkylarkParser.ConfigWithDependencies in project copybara by google.
the class InfoTest method testInfoUpToDate.
@Test
public void testInfoUpToDate() throws Exception {
info = new InfoCmd((configPath, sourceRef) -> new ConfigLoader(skylark.createModuleSet(), skylark.createConfigFile("copy.bara.sky", configInfo), optionsBuilder.general.getStarlarkMode()) {
@Override
public Config load(Console console) {
return config;
}
@Override
public ConfigWithDependencies loadWithDependencies(Console console) {
return configWithDeps;
}
}, getFakeContextProvider());
MigrationReference<DummyRevision> workflow = MigrationReference.create("workflow", new DummyRevision("1111"), ImmutableList.of());
Info<?> mockedInfo = Info.create(dummyOriginDescription, dummyDestinationDescription, ImmutableList.of(workflow));
Mockito.<Info<? extends Revision>>when(migration.getInfo()).thenReturn(mockedInfo);
info.run(new CommandEnv(temp, optionsBuilder.build(), ImmutableList.of("copy.bara.sky", "workflow")));
assertThat(eventMonitor.infoFinishedEvent).isNotNull();
assertThat(eventMonitor.infoFinishedEvent.getInfo()).isEqualTo(mockedInfo);
console.assertThat().onceInLog(MessageType.INFO, ".*last_migrated 1111 - last_available None.*");
}
Aggregations