From b85679f8dc5bf07bf45c2e4420022c439ebd3e00 Mon Sep 17 00:00:00 2001 From: Eryk Szymanski Date: Wed, 14 Nov 2018 15:07:32 -0800 Subject: [PATCH 1/5] Encode project name in download commands This allows to use download commands in case project name contains any special characters i.e. spaces Bug: Issue 10021 Change-Id: Iac4288559662b0a9beda3d33a06ef2e8c54bc338 Signed-off-by: Eryk Szymanski (cherry picked from commit 8a88d06df1f5dd5a572d1bae703710efa55d0acd) --- polygerrit-ui/app/elements/admin/gr-repo/gr-repo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.js b/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.js index 6443095a1a..77a1e2a3ec 100644 --- a/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.js +++ b/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.js @@ -307,9 +307,9 @@ commands.push({ title, command: commandObj[title] - .replace('${project}', repo) + .replace('${project}', encodeURI(repo)) .replace('${project-base-name}', - repo.substring(repo.lastIndexOf('/') + 1)), + encodeURI(repo.substring(repo.lastIndexOf('/') + 1))), }); } return commands; From f3f014c24f5cdeff59116b0ac26eee9af0dd26ce Mon Sep 17 00:00:00 2001 From: Hoa Tran Date: Sun, 11 Nov 2018 23:38:23 +0700 Subject: [PATCH 2/5] Correct javadoc @link to avoid warning in bazel build //... Bug: Issue 10004 Change-Id: I2dc7bd84623427d92fb939bcd4c58fbd185f535a --- .../gerrit/server/plugincontext/PluginSetEntryContext.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/java/com/google/gerrit/server/plugincontext/PluginSetEntryContext.java b/java/com/google/gerrit/server/plugincontext/PluginSetEntryContext.java index afffbef76a..2268c077e4 100644 --- a/java/com/google/gerrit/server/plugincontext/PluginSetEntryContext.java +++ b/java/com/google/gerrit/server/plugincontext/PluginSetEntryContext.java @@ -103,8 +103,9 @@ public class PluginSetEntryContext { * *

Should only be used in exceptional cases to get direct access to the extension * implementation. If possible the extension should be invoked through {@link - * #run(ExtensionImplConsumer)}, {@link #run(ExtensionImplConsumer, Class)}, {@link - * #call(ExtensionImplFunction)} and {@link #call(CheckedExtensionImplFunction, Class)}. + * #run(PluginContext.ExtensionImplConsumer)}, {@link #run(PluginContext.ExtensionImplConsumer, + * java.lang.Class)}, {@link #call(PluginContext.ExtensionImplFunction)} and {@link + * #call(PluginContext.CheckedExtensionImplFunction, java.lang.Class)}. * * @return the implementation of this extension */ From df511a5d4cc4efc22133cdc7fe61813782ce7504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20=C5=BDivkov?= Date: Fri, 16 Nov 2018 14:56:30 +0100 Subject: [PATCH 3/5] Honor --slave and --headless options better Looks like serving PolyGerrit UI never honored the --headless option. In addition, the StaticModule was unnecessarily installed when running in the slave mode. Don't install the StaticModule when running in the slave mode. Don't serve PolyGerrit UI when running in the headless mode. Change-Id: I480a9c33d596feba4516028491684832785b8dc4 --- java/com/google/gerrit/httpd/init/WebAppInitializer.java | 5 ++++- java/com/google/gerrit/httpd/raw/StaticModule.java | 4 +--- java/com/google/gerrit/pgm/Daemon.java | 5 ++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/java/com/google/gerrit/httpd/init/WebAppInitializer.java b/java/com/google/gerrit/httpd/init/WebAppInitializer.java index 624b307e32..db218d844a 100644 --- a/java/com/google/gerrit/httpd/init/WebAppInitializer.java +++ b/java/com/google/gerrit/httpd/init/WebAppInitializer.java @@ -443,7 +443,10 @@ public class WebAppInitializer extends GuiceServletContextListener implements Fi modules.add(sysInjector.getInstance(GetUserFilter.Module.class)); // StaticModule contains a "/*" wildcard, place it last. - modules.add(sysInjector.getInstance(StaticModule.class)); + GerritOptions opts = sysInjector.getInstance(GerritOptions.class); + if (opts.enableMasterFeatures()) { + modules.add(sysInjector.getInstance(StaticModule.class)); + } return sysInjector.createChildInjector(modules); } diff --git a/java/com/google/gerrit/httpd/raw/StaticModule.java b/java/com/google/gerrit/httpd/raw/StaticModule.java index 062d776b2d..fc6762bc9b 100644 --- a/java/com/google/gerrit/httpd/raw/StaticModule.java +++ b/java/com/google/gerrit/httpd/raw/StaticModule.java @@ -142,10 +142,8 @@ public class StaticModule extends ServletModule { }); if (!options.headless()) { install(new CoreStaticModule()); + install(new PolyGerritModule()); } - - install(new PolyGerritModule()); - if (options.enableGwtUi()) { install(new GwtUiModule()); } diff --git a/java/com/google/gerrit/pgm/Daemon.java b/java/com/google/gerrit/pgm/Daemon.java index a777a1cb29..fa7662da70 100644 --- a/java/com/google/gerrit/pgm/Daemon.java +++ b/java/com/google/gerrit/pgm/Daemon.java @@ -612,7 +612,10 @@ public class Daemon extends SiteProgram { modules.add(sysInjector.getInstance(GetUserFilter.Module.class)); // StaticModule contains a "/*" wildcard, place it last. - modules.add(sysInjector.getInstance(StaticModule.class)); + GerritOptions opts = sysInjector.getInstance(GerritOptions.class); + if (opts.enableMasterFeatures()) { + modules.add(sysInjector.getInstance(StaticModule.class)); + } return sysInjector.createChildInjector(modules); } From b3f84b2e693ea34309a15e9034483f94032168e1 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Mon, 26 Nov 2018 11:12:24 +0900 Subject: [PATCH 4/5] Allow plugin to bind a different implementation of UrlFormatter The UrlFormatter interface has a fixed binding to DefaultUrlFormatter which means an alternative binding cannot be provided by a plugin. Change it to a dynamic binding. Change-Id: I37524564793b7dc4cf2ead2161bf180f6266c9ab --- java/com/google/gerrit/server/config/DefaultUrlFormatter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/com/google/gerrit/server/config/DefaultUrlFormatter.java b/java/com/google/gerrit/server/config/DefaultUrlFormatter.java index 70fb46541d..060ee3f2d2 100644 --- a/java/com/google/gerrit/server/config/DefaultUrlFormatter.java +++ b/java/com/google/gerrit/server/config/DefaultUrlFormatter.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.config; +import com.google.gerrit.extensions.registration.DynamicItem; import com.google.inject.AbstractModule; import com.google.inject.Inject; import com.google.inject.Provider; @@ -27,7 +28,8 @@ public class DefaultUrlFormatter implements UrlFormatter { public static class Module extends AbstractModule { @Override protected void configure() { - bind(UrlFormatter.class).to(DefaultUrlFormatter.class); + DynamicItem.itemOf(binder(), UrlFormatter.class); + DynamicItem.bind(binder(), UrlFormatter.class).to(DefaultUrlFormatter.class); } } From e2f25beb345525ed4ae8cc1293d7cb668fdce1c3 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Mon, 26 Nov 2018 17:56:07 +0900 Subject: [PATCH 5/5] Document the UrlFormatter interface Change-Id: I048b0c1cac8a8b24999170512f66829b032e7f6d --- Documentation/dev-plugins.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/dev-plugins.txt b/Documentation/dev-plugins.txt index fd29bf7eb1..53b03b1ebe 100644 --- a/Documentation/dev-plugins.txt +++ b/Documentation/dev-plugins.txt @@ -2355,6 +2355,16 @@ By implementing the `com.google.gerrit.server.git.ChangeReportFormatter` interface, a plugin may change the formatting of the report. +[[url-formatting]] +== URL Formatting + +URLs to various parts of Gerrit are usually formed by adding suffixes to +the canonical web URL. + +By implementing the +`com.google.gerrit.server.config.UrlFormatter` interface, a plugin may +change the format of the URL. + [[links-to-external-tools]] == Links To External Tools