Format all Java files with google-java-format Change-Id: Iec0368bf90d394e0a98662e535ac082ad45f3bbb
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/Module.java b/src/main/java/com/googlesource/gerrit/plugins/download/Module.java index fa874d6..78d1f36 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/Module.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/Module.java
@@ -15,7 +15,6 @@ package com.googlesource.gerrit.plugins.download; import com.google.inject.AbstractModule; - import com.googlesource.gerrit.plugins.download.command.CloneCommandsModule; import com.googlesource.gerrit.plugins.download.command.DownloadCommandsModule; import com.googlesource.gerrit.plugins.download.scheme.SchemeModule;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/CheckoutCommand.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/CheckoutCommand.java index 79efede..8f66485 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/command/CheckoutCommand.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/CheckoutCommand.java
@@ -20,12 +20,12 @@ import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.inject.Inject; - import org.eclipse.jgit.lib.Config; class CheckoutCommand extends GitDownloadCommand { @Inject - CheckoutCommand(@GerritServerConfig Config cfg, + CheckoutCommand( + @GerritServerConfig Config cfg, DownloadConfig downloadConfig, GitRepositoryManager repoManager) { super(cfg, downloadConfig, CHECKOUT, repoManager);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/CherryPickCommand.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/CherryPickCommand.java index f0916d2..670af42 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/command/CherryPickCommand.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/CherryPickCommand.java
@@ -20,12 +20,12 @@ import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.inject.Inject; - import org.eclipse.jgit.lib.Config; class CherryPickCommand extends GitDownloadCommand { @Inject - CherryPickCommand(@GerritServerConfig Config cfg, + CherryPickCommand( + @GerritServerConfig Config cfg, DownloadConfig downloadConfig, GitRepositoryManager repoManager) { super(cfg, downloadConfig, CHERRY_PICK, repoManager);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneCommandsModule.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneCommandsModule.java index acd867c..5e55fd6 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneCommandsModule.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneCommandsModule.java
@@ -22,8 +22,8 @@ @Override protected void configure() { bind(CloneCommand.class) - .annotatedWith(Exports.named("Clone")) - .to(com.googlesource.gerrit.plugins.download.command.CloneCommand.class); + .annotatedWith(Exports.named("Clone")) + .to(com.googlesource.gerrit.plugins.download.command.CloneCommand.class); bind(CloneCommand.class) .annotatedWith(Exports.named("Clone with commit-msg hook"))
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 dcf7503..79cf187 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
@@ -19,11 +19,9 @@ import com.google.gerrit.server.config.GerritServerConfig; import com.google.inject.Inject; import com.google.inject.Provider; - 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 org.eclipse.jgit.lib.Config; public class CloneWithCommitMsgHook extends CloneCommand { @@ -36,11 +34,8 @@ @Inject CloneWithCommitMsgHook( - @GerritServerConfig Config config, - SshScheme sshScheme, - Provider<CurrentUser> userProvider) { - this.configCommand = - config.getString("gerrit", null, "installCommitMsgHookCommand"); + @GerritServerConfig Config config, SshScheme sshScheme, Provider<CurrentUser> userProvider) { + this.configCommand = config.getString("gerrit", null, "installCommitMsgHookCommand"); this.sshScheme = sshScheme; this.userProvider = userProvider; } @@ -65,9 +60,8 @@ } if (scheme instanceof SshScheme) { - StringBuilder b = new StringBuilder() - .append(super.getCommand(scheme, project)) - .append(" && scp -p"); + StringBuilder b = + new StringBuilder().append(super.getCommand(scheme, project)).append(" && scp -p"); if (sshScheme.getSshdPort() != 22) { b.append(" -P ").append(sshScheme.getSshdPort());
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/DownloadCommandsModule.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/DownloadCommandsModule.java index 22ca5d3..c2a4289 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/command/DownloadCommandsModule.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/DownloadCommandsModule.java
@@ -21,24 +21,18 @@ public class DownloadCommandsModule extends AbstractModule { @Override protected void configure() { - bind(DownloadCommand.class) - .annotatedWith(Exports.named("Checkout")) - .to(CheckoutCommand.class); + bind(DownloadCommand.class).annotatedWith(Exports.named("Checkout")).to(CheckoutCommand.class); bind(DownloadCommand.class) - .annotatedWith(Exports.named("Cherry Pick")) - .to(CherryPickCommand.class); + .annotatedWith(Exports.named("Cherry Pick")) + .to(CherryPickCommand.class); bind(DownloadCommand.class) - .annotatedWith(Exports.named("Format Patch")) - .to(FormatPatchCommand.class); + .annotatedWith(Exports.named("Format Patch")) + .to(FormatPatchCommand.class); - bind(DownloadCommand.class) - .annotatedWith(Exports.named("Pull")) - .to(PullCommand.class); + bind(DownloadCommand.class).annotatedWith(Exports.named("Pull")).to(PullCommand.class); - bind(DownloadCommand.class) - .annotatedWith(Exports.named("repo")) - .to(RepoCommand.class); + bind(DownloadCommand.class).annotatedWith(Exports.named("repo")).to(RepoCommand.class); } }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/FormatPatchCommand.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/FormatPatchCommand.java index 6a120ff..9ca69ce 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/command/FormatPatchCommand.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/FormatPatchCommand.java
@@ -20,12 +20,12 @@ import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.inject.Inject; - import org.eclipse.jgit.lib.Config; class FormatPatchCommand extends GitDownloadCommand { @Inject - FormatPatchCommand(@GerritServerConfig Config cfg, + FormatPatchCommand( + @GerritServerConfig Config cfg, DownloadConfig downloadConfig, GitRepositoryManager repoManager) { super(cfg, downloadConfig, FORMAT_PATCH, repoManager);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/GitDownloadCommand.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/GitDownloadCommand.java index 03b817d..b5062f6 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/command/GitDownloadCommand.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/GitDownloadCommand.java
@@ -22,9 +22,10 @@ import com.google.gerrit.server.config.DownloadConfig; import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.git.GitRepositoryManager; - import com.googlesource.gerrit.plugins.download.scheme.RepoScheme; - +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.Arrays; import org.eclipse.jgit.errors.RepositoryNotFoundException; import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.ObjectId; @@ -33,13 +34,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.Arrays; - abstract class GitDownloadCommand extends DownloadCommand { - private static final Logger log = - LoggerFactory.getLogger(GitDownloadCommand.class); + private static final Logger log = LoggerFactory.getLogger(GitDownloadCommand.class); private static final String DOWNLOAD = "download"; private static final String UPLOADPACK = "uploadpack"; @@ -52,7 +48,8 @@ private final GitRepositoryManager repoManager; private final boolean checkForHiddenChangeRefs; - GitDownloadCommand(@GerritServerConfig Config cfg, + GitDownloadCommand( + @GerritServerConfig Config cfg, DownloadConfig downloadConfig, GeneralPreferencesInfo.DownloadCommand cmd, GitRepositoryManager repoManager) { @@ -63,8 +60,7 @@ } @Override - public final String getCommand(DownloadScheme scheme, String project, - String ref) { + public final String getCommand(DownloadScheme scheme, String project, String ref) { if (commandAllowed && isRecognizedScheme(scheme)) { String url = scheme.getUrl(project); if (url != null && isValidUrl(url)) { @@ -101,8 +97,8 @@ try (Repository repo = repoManager.openRepository(new Project.NameKey(project))) { Config cfg = repo.getConfig(); boolean allowSha1InWant = - cfg.getBoolean(UPLOADPACK, KEY_ALLOW_TIP_SHA1_IN_WANT, false) || - cfg.getBoolean(UPLOADPACK, KEY_ALLOW_REACHABLE_SHA1_IN_WANT, false); + cfg.getBoolean(UPLOADPACK, KEY_ALLOW_TIP_SHA1_IN_WANT, false) + || cfg.getBoolean(UPLOADPACK, KEY_ALLOW_REACHABLE_SHA1_IN_WANT, false); if (allowSha1InWant && Arrays.asList(cfg.getStringList(UPLOADPACK, null, KEY_HIDE_REFS)) .contains(RefNames.REFS_CHANGES)) { @@ -110,17 +106,15 @@ if (id != null) { return id.name(); } - log.error(String.format("Cannot resolve ref %s in project %s.", ref, - project)); + log.error(String.format("Cannot resolve ref %s in project %s.", ref, project)); return null; } return ref; } catch (RepositoryNotFoundException e) { - log.error(String.format("Missing project: %s", project), e); + log.error(String.format("Missing project: %s", project), e); return null; } catch (IOException e) { - log.error( - String.format("Failed to lookup project %s from cache.", project), e); + log.error(String.format("Failed to lookup project %s from cache.", project), e); return null; } }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/PullCommand.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/PullCommand.java index 309f5b2..5544925 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/command/PullCommand.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/PullCommand.java
@@ -20,12 +20,12 @@ import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.inject.Inject; - import org.eclipse.jgit.lib.Config; class PullCommand extends GitDownloadCommand { @Inject - PullCommand(@GerritServerConfig Config cfg, + PullCommand( + @GerritServerConfig Config cfg, DownloadConfig downloadConfig, GitRepositoryManager repoManager) { super(cfg, downloadConfig, PULL, repoManager);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/RepoCommand.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/RepoCommand.java index 5bb38bb..4322f76 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/command/RepoCommand.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/RepoCommand.java
@@ -17,7 +17,6 @@ import com.google.gerrit.extensions.config.DownloadCommand; import com.google.gerrit.extensions.config.DownloadScheme; import com.google.gerrit.reviewdb.client.RefNames; - import com.googlesource.gerrit.plugins.download.scheme.RepoScheme; public class RepoCommand extends DownloadCommand {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/AnonymousHttpScheme.java b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/AnonymousHttpScheme.java index 03cf056..45eaab2 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/AnonymousHttpScheme.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/AnonymousHttpScheme.java
@@ -23,7 +23,6 @@ import com.google.gerrit.server.config.GerritServerConfig; import com.google.inject.Inject; import com.google.inject.Provider; - import org.eclipse.jgit.lib.Config; public class AnonymousHttpScheme extends DownloadScheme { @@ -33,13 +32,13 @@ private final boolean schemeAllowed; @Inject - public AnonymousHttpScheme(@GerritServerConfig Config cfg, + public AnonymousHttpScheme( + @GerritServerConfig Config cfg, @CanonicalWebUrl @Nullable Provider<String> provider, DownloadConfig downloadConfig) { this.gitHttpUrl = ensureSlash(cfg.getString("gerrit", null, "gitHttpUrl")); this.canonicalWebUrl = provider != null ? provider.get() : null; - this.schemeAllowed = - downloadConfig.getDownloadSchemes().contains(ANON_HTTP); + this.schemeAllowed = downloadConfig.getDownloadSchemes().contains(ANON_HTTP); } @Override
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/GitScheme.java b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/GitScheme.java index 8ff7555..f6fc9ae 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/GitScheme.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/GitScheme.java
@@ -20,7 +20,6 @@ import com.google.gerrit.server.config.DownloadConfig; import com.google.gerrit.server.config.GerritServerConfig; import com.google.inject.Inject; - import org.eclipse.jgit.lib.Config; public class GitScheme extends DownloadScheme { @@ -29,10 +28,8 @@ private final boolean schemeAllowed; @Inject - public GitScheme(@GerritServerConfig Config cfg, - DownloadConfig downloadConfig) { - this.gitDaemonUrl = - ensureSlash(cfg.getString("gerrit", null, "canonicalGitUrl")); + public GitScheme(@GerritServerConfig Config cfg, DownloadConfig downloadConfig) { + this.gitDaemonUrl = ensureSlash(cfg.getString("gerrit", null, "canonicalGitUrl")); this.schemeAllowed = downloadConfig.getDownloadSchemes().contains(ANON_GIT); }
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 e02b1f8..0e5bbee 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
@@ -24,7 +24,6 @@ import com.google.gerrit.server.config.GerritServerConfig; import com.google.inject.Inject; import com.google.inject.Provider; - import org.eclipse.jgit.lib.Config; public class HttpScheme extends DownloadScheme { @@ -35,7 +34,8 @@ private final boolean schemeAllowed; @Inject - public HttpScheme(@GerritServerConfig Config cfg, + public HttpScheme( + @GerritServerConfig Config cfg, @CanonicalWebUrl @Nullable Provider<String> urlProvider, Provider<CurrentUser> userProvider, DownloadConfig downloadConfig) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SchemeModule.java b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SchemeModule.java index 9a42fcc..5ff04b2 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SchemeModule.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SchemeModule.java
@@ -22,23 +22,15 @@ @Override protected void configure() { bind(DownloadScheme.class) - .annotatedWith(Exports.named("anonymous http")) - .to(AnonymousHttpScheme.class); + .annotatedWith(Exports.named("anonymous http")) + .to(AnonymousHttpScheme.class); - bind(DownloadScheme.class) - .annotatedWith(Exports.named("git")) - .to(GitScheme.class); + bind(DownloadScheme.class).annotatedWith(Exports.named("git")).to(GitScheme.class); - bind(DownloadScheme.class) - .annotatedWith(Exports.named("http")) - .to(HttpScheme.class); + bind(DownloadScheme.class).annotatedWith(Exports.named("http")).to(HttpScheme.class); - bind(DownloadScheme.class) - .annotatedWith(Exports.named("repo")) - .to(RepoScheme.class); + bind(DownloadScheme.class).annotatedWith(Exports.named("repo")).to(RepoScheme.class); - bind(DownloadScheme.class) - .annotatedWith(Exports.named("ssh")) - .to(SshScheme.class); + bind(DownloadScheme.class).annotatedWith(Exports.named("ssh")).to(SshScheme.class); } }
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 43b3cc2..ac198fb 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
@@ -25,7 +25,6 @@ import com.google.gerrit.server.ssh.SshAdvertisedAddresses; import com.google.inject.Inject; import com.google.inject.Provider; - import java.net.MalformedURLException; import java.net.URL; import java.util.List; @@ -38,11 +37,14 @@ private final boolean schemeAllowed; @Inject - SshScheme(@SshAdvertisedAddresses List<String> sshAddresses, + SshScheme( + @SshAdvertisedAddresses List<String> sshAddresses, @CanonicalWebUrl @Nullable Provider<String> urlProvider, - Provider<CurrentUser> userProvider, DownloadConfig downloadConfig) { + Provider<CurrentUser> userProvider, + DownloadConfig downloadConfig) { String sshAddr = !sshAddresses.isEmpty() ? sshAddresses.get(0) : null; - if (sshAddr != null && (sshAddr.startsWith("*:") || "".equals(sshAddr)) + if (sshAddr != null + && (sshAddr.startsWith("*:") || "".equals(sshAddr)) && urlProvider != null) { try { sshAddr = (new URL(urlProvider.get())).getHost() + sshAddr.substring(1);