summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Ares <hugo.ares@ericsson.com>2013-10-03 15:37:16 -0400
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-02-10 21:05:42 +0000
commit623239c9a172f9eb143fe6325069cec237604a97 (patch)
tree9a4261dfcf50defd9b29403371c635b9aa1106e5
parent9d8d29e97b2ad94a2684b0956a15506836e8eff3 (diff)
Add port to replication status and display path for local replication
Replication status was only displaying the hostname. It is impossible to differentiate replication status when 2 urls use the same hostname with different ports. Replication status now displays host[:port] and if the replication url does not have host(file:///), displays the path instead. Here are some examples of replication url and the replication status that is displayed: -url = git://someHost.com/${name}.git Replicate project1 to someHost, Succeeded! -url = git://someHost:1234/${name}.git Replicate project1 to someHost:1234, Succeeded! -url = file:///somePath/git/${name}.git Replicate project1 to /somePath/git/project1.git, Succeeded! Change-Id: Ia86154cb9f26dfdcae37dc9993fe2cd0f7c37838 (cherry picked from commit 87d7a646419badac537f83ca8b8c1858e06d9b25) Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/PushResultProcessing.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/PushResultProcessing.java b/src/main/java/com/googlesource/gerrit/plugins/replication/PushResultProcessing.java
index 27c8b85..0452b69 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushResultProcessing.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushResultProcessing.java
@@ -34,6 +34,20 @@ public abstract class PushResultProcessing {
// Default doing nothing
}
+ private static String resolveNodeName(URIish uri) {
+ StringBuilder sb = new StringBuilder();
+ if (uri.isRemote()) {
+ sb.append(uri.getHost());
+ if (uri.getPort() != -1) {
+ sb.append(":");
+ sb.append(uri.getPort());
+ }
+ } else {
+ sb.append(uri.getPath());
+ }
+ return sb.toString();
+ }
+
public static class CommandProcessing extends PushResultProcessing {
private WeakReference<StartCommand> sshCommand;
private AtomicBoolean hasError = new AtomicBoolean();
@@ -49,11 +63,7 @@ public abstract class PushResultProcessing {
sb.append("Replicate ");
sb.append(project);
sb.append(" to ");
- if (uri.getHost() != null) {
- sb.append(uri.getHost());
- } else {
- sb.append("localhost");
- }
+ sb.append(resolveNodeName(uri));
sb.append(", ");
switch (status) {
case SUCCEEDED: