From 97b02cd3e5bde90f412882431dd489225da9d0e0 Mon Sep 17 00:00:00 2001 From: Andrew Erickson Date: Fri, 16 Nov 2012 19:48:03 -0800 Subject: [PATCH] getOfflineCauseReason handles localization also handles usernames that are emails --- core/src/main/java/hudson/model/Computer.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/hudson/model/Computer.java b/core/src/main/java/hudson/model/Computer.java index b500ee8096..6409ebab32 100644 --- a/core/src/main/java/hudson/model/Computer.java +++ b/core/src/main/java/hudson/model/Computer.java @@ -264,12 +264,15 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces if (offlineCause == null) { return ""; } - // remove header string from offline cause when a comment was set - String newString = offlineCause.toString().replaceAll( - "^Disconnected by [\\w]* \\: ",""); - // remove header string from offline cause when no comment was set - return newString.replaceAll( - "^Disconnected by [\\w]*",""); + // fetch the localized string for "Disconnected By" + String gsub_base = hudson.slaves.Messages.SlaveComputer_DisconnectedBy("",""); + // regex to remove commented reason base string + String gsub1 = "^" + gsub_base + "[\\w\\W]* \\: "; + // regex to remove non-commented reason base string + String gsub2 = "^" + gsub_base + "[\\w\\W]*"; + + String newString = offlineCause.toString().replaceAll(gsub1, ""); + return newString.replaceAll(gsub2, ""); } /** -- GitLab