use of com.google.copybara.monitor.EventMonitor.InfoFinishedEvent in project copybara by google.
the class Copybara method info.
/**
* Retrieves the {@link Info} of the {@code migrationName} and prints it to the console.
*/
public void info(Options options, Config config, String migrationName) throws ValidationException, RepoException {
@SuppressWarnings("unchecked") Info<? extends Revision> info = getInfo(migrationName, config);
Console console = options.get(GeneralOptions.class).console();
int outputSize = 0;
for (MigrationReference<? extends Revision> migrationRef : info.migrationReferences()) {
console.info(String.format("'%s': last_migrated %s - last_available %s.", migrationRef.getLabel(), migrationRef.getLastMigrated() != null ? migrationRef.getLastMigrated().asString() : "None", migrationRef.getLastAvailableToMigrate() != null ? migrationRef.getLastAvailableToMigrate().asString() : "None"));
ImmutableList<? extends Change<? extends Revision>> availableToMigrate = migrationRef.getAvailableToMigrate();
int outputLimit = options.get(GeneralOptions.class).getOutputLimit();
if (!availableToMigrate.isEmpty()) {
console.infoFmt("Available changes%s:", availableToMigrate.size() <= outputLimit ? "" : String.format(" (showing only first %d out of %d)", outputLimit, availableToMigrate.size()));
int changeNumber = 1;
for (Change<? extends Revision> change : Iterables.limit(availableToMigrate, outputLimit)) {
outputSize++;
console.info(String.format("%d - %s %s by %s", changeNumber++, change.getRevision().asString(), change.firstLineMessage(), change.getAuthor()));
}
}
// TODO(danielromero): Check flag usage on 2018-06 and decide if we keep it
if (outputSize > 100) {
console.infoFmt("Use %s to limit the output of the command.", GeneralOptions.OUTPUT_LIMIT_FLAG);
}
}
options.get(GeneralOptions.class).eventMonitor().onInfoFinished(new InfoFinishedEvent(info));
}
Aggregations