You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2023/09/11 15:02:26 UTC
[maven] branch MNG-7875_transfer_color updated (a6de9b0913 -> 43f6cef00a)
This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a change to branch MNG-7875_transfer_color
in repository https://gitbox.apache.org/repos/asf/maven.git
omit a6de9b0913 [MNG-7875] colorize transfer messages
new 43f6cef00a [MNG-7875] colorize transfer messages
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (a6de9b0913)
\
N -- N -- N refs/heads/MNG-7875_transfer_color (43f6cef00a)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../transfer/AbstractMavenTransferListener.java | 28 ++++------------------
1 file changed, 4 insertions(+), 24 deletions(-)
[maven] 01/01: [MNG-7875] colorize transfer messages
Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a commit to branch MNG-7875_transfer_color
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 43f6cef00a283d63b5c999d91b9e2b63eff1cc03
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sun Sep 10 08:45:31 2023 +0200
[MNG-7875] colorize transfer messages
---
.../transfer/AbstractMavenTransferListener.java | 29 ++++++++++++++++------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
index 7e71925b5c..e91be53209 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
@@ -24,6 +24,7 @@ import java.text.DecimalFormatSymbols;
import java.util.Locale;
import org.apache.commons.lang3.Validate;
+import org.apache.maven.shared.utils.logging.MessageUtils;
import org.eclipse.aether.transfer.AbstractTransferListener;
import org.eclipse.aether.transfer.TransferCancelledException;
import org.eclipse.aether.transfer.TransferEvent;
@@ -34,6 +35,10 @@ import org.eclipse.aether.transfer.TransferResource;
*/
public abstract class AbstractMavenTransferListener extends AbstractTransferListener {
+ private static final String ESC = "\u001B";
+ private static final String ANSI_DARK_SET = ESC + "[90m";
+ private static final String ANSI_DARK_RESET = ESC + "[0m";
+
// CHECKSTYLE_OFF: LineLength
/**
* Formats file size with the associated <a href="https://en.wikipedia.org/wiki/Metric_prefix">SI</a> prefix
@@ -184,14 +189,18 @@ public abstract class AbstractMavenTransferListener extends AbstractTransferList
@Override
public void transferInitiated(TransferEvent event) {
+ String darkOn = MessageUtils.isColorEnabled() ? ANSI_DARK_SET : "";
+ String darkOff = MessageUtils.isColorEnabled() ? ANSI_DARK_RESET : "";
+
String action = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading";
String direction = event.getRequestType() == TransferEvent.RequestType.PUT ? "to" : "from";
TransferResource resource = event.getResource();
StringBuilder message = new StringBuilder();
- message.append(action).append(' ').append(direction).append(' ').append(resource.getRepositoryId());
- message.append(": ");
- message.append(resource.getRepositoryUrl()).append(resource.getResourceName());
+ message.append(darkOn).append(action).append(' ').append(direction).append(' ');
+ message.append(darkOff).append(resource.getRepositoryId());
+ message.append(darkOn).append(": ").append(resource.getRepositoryUrl());
+ message.append(darkOff).append(resource.getResourceName());
out.println(message.toString());
}
@@ -206,6 +215,9 @@ public abstract class AbstractMavenTransferListener extends AbstractTransferList
@Override
public void transferSucceeded(TransferEvent event) {
+ String darkOn = MessageUtils.isColorEnabled() ? ANSI_DARK_SET : "";
+ String darkOff = MessageUtils.isColorEnabled() ? ANSI_DARK_RESET : "";
+
String action = (event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded");
String direction = event.getRequestType() == TransferEvent.RequestType.PUT ? "to" : "from";
@@ -214,10 +226,11 @@ public abstract class AbstractMavenTransferListener extends AbstractTransferList
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
StringBuilder message = new StringBuilder();
- message.append(action).append(' ').append(direction).append(' ').append(resource.getRepositoryId());
- message.append(": ");
- message.append(resource.getRepositoryUrl()).append(resource.getResourceName());
- message.append(" (").append(format.format(contentLength));
+ message.append(action).append(darkOn).append(' ').append(direction).append(' ');
+ message.append(darkOff).append(resource.getRepositoryId());
+ message.append(darkOn).append(": ").append(resource.getRepositoryUrl());
+ message.append(darkOff).append(resource.getResourceName());
+ message.append(darkOn).append(" (").append(format.format(contentLength));
long duration = System.currentTimeMillis() - resource.getTransferStartTime();
if (duration > 0L) {
@@ -225,7 +238,7 @@ public abstract class AbstractMavenTransferListener extends AbstractTransferList
message.append(" at ").append(format.format((long) bytesPerSecond)).append("/s");
}
- message.append(')');
+ message.append(')').append(darkOff);
out.println(message.toString());
}
}