Fix Git message logging.

Closes #98
This commit is contained in:
Mark Paluch
2024-10-17 08:32:37 +02:00
parent e0b6b98769
commit b20835640a
2 changed files with 26 additions and 4 deletions

View File

@@ -292,16 +292,35 @@ public class GitOperations {
if (success.contains(remoteUpdate.getStatus())) {
logger.log(module, String.format("✅️ Push done: %s %s", remoteUpdate.getStatus(),
logger.log(module.getProject().getName(), String.format("✅️ Push done: %s %s", getMessage(remoteUpdate),
StringUtils.hasText(remoteUpdate.getMessage()) ? remoteUpdate.getMessage() : ""));
continue;
}
logger.warn(module, String.format("⚠️ Push failed: %s %s", remoteUpdate.getStatus(), remoteUpdate.getMessage()));
logger.warn(module.getProject().getName(),
String.format("⚠️ Push failed: %s %s", getMessage(remoteUpdate), remoteUpdate.getMessage()));
}
}
private static String getMessage(RemoteRefUpdate remoteUpdate) {
RemoteRefUpdate.Status status = remoteUpdate.getStatus();
switch (status) {
case UP_TO_DATE:
return "Branch up-to-date";
case REJECTED_REMOTE_CHANGED:
return "Remote branch changed";
case NON_EXISTING:
return "Remote branch does not exist";
case AWAITING_REPORT:
return "Awaiting report…";
}
return status.name();
}
public void pushTags(Train train) {
ExecutionUtils.run(executor, train.getModules(), module -> {

View File

@@ -23,6 +23,7 @@ import org.springframework.data.release.model.Train;
import org.springframework.data.release.model.TrainIteration;
import org.springframework.shell.support.logging.HandlerUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
/**
* @author Oliver Gierke
@@ -56,7 +57,8 @@ public class Logger {
}
public void log(String context, Object template, Object... args) {
LOGGER.info(String.format(PREFIX_TEMPLATE, context, String.format(template.toString(), args)));
LOGGER.info(String.format(PREFIX_TEMPLATE, context,
ObjectUtils.isEmpty(args) ? template.toString() : String.format(template.toString(), args)));
}
public void warn(ModuleIteration module, Object template, Object... args) {
@@ -76,6 +78,7 @@ public class Logger {
}
public void warn(String context, Object template, Object... args) {
LOGGER.warning(String.format(PREFIX_TEMPLATE, context, String.format(template.toString(), args)));
LOGGER.warning(String.format(PREFIX_TEMPLATE, context,
ObjectUtils.isEmpty(args) ? template.toString() : String.format(template.toString(), args)));
}
}