Merge branch 'stable-2.15'

* stable-2.15:
  GitDownloadCommand: Use Logger's built-in string formatting

Change-Id: I2d30fac015a43657fd10c91095896390563b40e5
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneWithCommitMsgHook.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneWithCommitMsgHook.java
index a0ed759..8c394cc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneWithCommitMsgHook.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneWithCommitMsgHook.java
@@ -22,6 +22,7 @@
 import com.googlesource.gerrit.plugins.download.scheme.AnonymousHttpScheme;
 import com.googlesource.gerrit.plugins.download.scheme.HttpScheme;
 import com.googlesource.gerrit.plugins.download.scheme.SshScheme;
+import java.util.Optional;
 import org.eclipse.jgit.lib.Config;
 
 public class CloneWithCommitMsgHook extends CloneCommand {
@@ -42,8 +43,8 @@
 
   @Override
   public String getCommand(DownloadScheme scheme, String project) {
-    String username = userProvider.get().getUserName();
-    if (username == null) {
+    Optional<String> username = userProvider.get().getUserName();
+    if (!username.isPresent()) {
       return null;
     }
     String projectName = getBaseName(project);
@@ -68,7 +69,7 @@
       }
 
       b.append(" ")
-          .append(username)
+          .append(username.get())
           .append("@")
           .append(sshScheme.getSshdHost())
           .append(":")
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/HttpScheme.java b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/HttpScheme.java
index 0e5bbee..3fabaa5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/HttpScheme.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/HttpScheme.java
@@ -63,8 +63,10 @@
       }
       String host = base.substring(p + 3, s);
       r.append(base.substring(0, p + 3));
-      r.append(userProvider.get().getUserName());
-      r.append("@");
+      if (userProvider.get().getUserName().isPresent()) {
+        r.append(userProvider.get().getUserName().get());
+        r.append("@");
+      }
       r.append(host);
       r.append(base.substring(s));
       r.append("a/");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SshScheme.java b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SshScheme.java
index ac198fb..e775d95 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SshScheme.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SshScheme.java
@@ -16,7 +16,6 @@
 
 import static com.google.gerrit.reviewdb.client.CoreDownloadSchemes.SSH;
 
-import com.google.common.base.Strings;
 import com.google.gerrit.common.Nullable;
 import com.google.gerrit.extensions.config.DownloadScheme;
 import com.google.gerrit.server.CurrentUser;
@@ -28,6 +27,7 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.List;
+import java.util.Optional;
 
 public class SshScheme extends DownloadScheme {
   private final String sshdAddress;
@@ -84,14 +84,15 @@
     if (!isEnabled() || !userProvider.get().isIdentifiedUser()) {
       return null;
     }
-    String username = userProvider.get().getUserName();
-    if (Strings.isNullOrEmpty(username)) {
+
+    Optional<String> username = userProvider.get().getUserName();
+    if (!username.isPresent()) {
       return null;
     }
 
     StringBuilder r = new StringBuilder();
     r.append("ssh://");
-    r.append(username);
+    r.append(username.get());
     r.append("@");
     r.append(ensureSlash(sshdAddress));
     r.append(project);