From 1619197851f6ab44611ee74a937f68e433ea007d Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Tue, 9 Jun 2015 15:44:41 -0700 Subject: [PATCH 1/5] GitWebConfig: Fix check for set-to-empty-string Config.getString returns null if the string is set to an empty value. This is, depending on your point of view, either a bug in JGit or defined but confusing behavior. Alas, the only reliable way of checking for the empty string in current JGit is to look for the value as a string list. Change-Id: I7603af40699516274f1063d1354f3234fdb6a3d9 --- .../google/gerrit/server/config/GitWebConfig.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java index 158c8a8af1..00767a16e9 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.config; import static java.nio.file.Files.isExecutable; import static java.nio.file.Files.isRegularFile; +import com.google.common.base.Strings; import com.google.gerrit.common.data.GitWebType; import com.google.inject.Inject; @@ -30,6 +31,14 @@ import java.nio.file.Paths; public class GitWebConfig { private static final Logger log = LoggerFactory.getLogger(GitWebConfig.class); + private static boolean isEmptyString(Config cfg, String section, + String subsection, String name) { + // This is currently the only way to check for the empty string in a JGit + // config. Fun! + String[] values = cfg.getStringList(section, subsection, name); + return values.length > 0 && Strings.isNullOrEmpty(values[0]); + } + private final String url; private final Path gitweb_cgi; private final Path gitweb_css; @@ -95,8 +104,8 @@ public class GitWebConfig { type = null; } - if ((cfgUrl != null && cfgUrl.isEmpty()) - || (cfgCgi != null && cfgCgi.isEmpty())) { + if (isEmptyString(cfg, "gitweb", null, "url") + || isEmptyString(cfg, "gitweb", null, "cgi")) { // Either setting was explicitly set to the empty string disabling // gitweb for this server. Disable the configuration. // From 1b2d47e7a2a0e37177c5c7a79caa509c22384e85 Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Fri, 5 Jun 2015 13:54:26 -0700 Subject: [PATCH 2/5] Extract CGI configuration from GitWebConfig GitWebConfig was used for two separate things: 1. Encapsulating the (type, GitWebConfig) pair that gets passed through the GerritConfig to the host page. 2. Describing the configuration for the built-in CGI servlet in the gitweb package. Separate these concerns, creating GitWebCgiConfig in the same config package as GitWebConfig. (Although it contains configuration for the httpd functionality, it needs to live in the server package so other server classes can check the configuration status.) Change-Id: I002beb892d415eb41a15829e6c5d540be253e390 --- .../com/google/gerrit/httpd/WebModule.java | 10 +- .../gerrit/httpd/gitweb/GitLogoServlet.java | 6 +- .../gerrit/httpd/gitweb/GitWebCssServlet.java | 6 +- .../httpd/gitweb/GitWebJavaScriptServlet.java | 6 +- .../gerrit/httpd/gitweb/GitWebServlet.java | 6 +- .../gerrit/server/config/GitWebCgiConfig.java | 137 +++++++++++++++ .../gerrit/server/config/GitWebConfig.java | 159 ++++-------------- 7 files changed, 185 insertions(+), 145 deletions(-) create mode 100644 gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebCgiConfig.java diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/WebModule.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/WebModule.java index 423e691eb9..d5f11004fa 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/WebModule.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/WebModule.java @@ -30,7 +30,7 @@ import com.google.gerrit.server.RemotePeer; import com.google.gerrit.server.config.AuthConfig; import com.google.gerrit.server.config.CanonicalWebUrl; import com.google.gerrit.server.config.GerritRequestModule; -import com.google.gerrit.server.config.GitWebConfig; +import com.google.gerrit.server.config.GitWebCgiConfig; import com.google.gerrit.server.git.AsyncReceiveCommits; import com.google.gerrit.server.util.GuiceRequestScopePropagator; import com.google.gerrit.server.util.RequestScopePropagator; @@ -43,18 +43,18 @@ import java.net.SocketAddress; public class WebModule extends LifecycleModule { private final AuthConfig authConfig; private final boolean wantSSL; - private final GitWebConfig gitWebConfig; + private final GitWebCgiConfig gitWebCgiConfig; private final GerritOptions options; @Inject WebModule(AuthConfig authConfig, @CanonicalWebUrl @Nullable String canonicalUrl, GerritOptions options, - GitWebConfig gitWebConfig) { + GitWebCgiConfig gitWebCgiConfig) { this.authConfig = authConfig; this.wantSSL = canonicalUrl != null && canonicalUrl.startsWith("https:"); this.options = options; - this.gitWebConfig = gitWebConfig; + this.gitWebCgiConfig = gitWebCgiConfig; } @Override @@ -75,7 +75,7 @@ public class WebModule extends LifecycleModule { install(new GerritRequestModule()); install(new GitOverHttpServlet.Module(options.enableMasterFeatures())); - if (gitWebConfig.getGitwebCGI() != null) { + if (gitWebCgiConfig.getGitwebCgi() != null) { install(new GitWebModule()); } diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitLogoServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitLogoServlet.java index 2bb31c7bce..62dfc24a47 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitLogoServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitLogoServlet.java @@ -17,7 +17,7 @@ package com.google.gerrit.httpd.gitweb; import static com.google.gerrit.common.FileUtil.lastModified; import com.google.common.io.ByteStreams; -import com.google.gerrit.server.config.GitWebConfig; +import com.google.gerrit.server.config.GitWebCgiConfig; import com.google.gwtexpui.server.CacheHeaders; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -41,9 +41,9 @@ class GitLogoServlet extends HttpServlet { private final byte[] raw; @Inject - GitLogoServlet(GitWebConfig gitWebConfig) throws IOException { + GitLogoServlet(GitWebCgiConfig cfg) throws IOException { byte[] png; - Path src = gitWebConfig.getGitLogoPNG(); + Path src = cfg.getGitLogoPng(); if (src != null) { try (InputStream in = Files.newInputStream(src)) { png = ByteStreams.toByteArray(in); diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebCssServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebCssServlet.java index bddcb2396b..5ea2253baa 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebCssServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebCssServlet.java @@ -17,7 +17,7 @@ package com.google.gerrit.httpd.gitweb; import static com.google.gerrit.common.FileUtil.lastModified; import com.google.gerrit.httpd.HtmlDomUtil; -import com.google.gerrit.server.config.GitWebConfig; +import com.google.gerrit.server.config.GitWebCgiConfig; import com.google.gerrit.server.config.SitePaths; import com.google.gwtexpui.server.CacheHeaders; import com.google.gwtjsonrpc.server.RPCServletUtils; @@ -46,8 +46,8 @@ abstract class GitWebCssServlet extends HttpServlet { @Singleton static class Default extends GitWebCssServlet { @Inject - Default(GitWebConfig gwc) throws IOException { - super(gwc.getGitwebCSS()); + Default(GitWebCgiConfig gwcc) throws IOException { + super(gwcc.getGitwebCss()); } } diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebJavaScriptServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebJavaScriptServlet.java index 9924f2938f..617167b751 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebJavaScriptServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebJavaScriptServlet.java @@ -17,7 +17,7 @@ package com.google.gerrit.httpd.gitweb; import static com.google.gerrit.common.FileUtil.lastModified; import com.google.common.io.ByteStreams; -import com.google.gerrit.server.config.GitWebConfig; +import com.google.gerrit.server.config.GitWebCgiConfig; import com.google.gwtexpui.server.CacheHeaders; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -41,9 +41,9 @@ class GitWebJavaScriptServlet extends HttpServlet { private final byte[] raw; @Inject - GitWebJavaScriptServlet(final GitWebConfig gitWebConfig) throws IOException { + GitWebJavaScriptServlet(GitWebCgiConfig gitWebCgiConfig) throws IOException { byte[] png; - Path src = gitWebConfig.getGitwebJS(); + Path src = gitWebCgiConfig.getGitwebJs(); if (src != null) { try (InputStream in = Files.newInputStream(src)) { png = ByteStreams.toByteArray(in); diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebServlet.java index 2fec04f22a..57126a5642 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebServlet.java @@ -38,6 +38,7 @@ import com.google.gerrit.server.AnonymousUser; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.config.GerritServerConfig; +import com.google.gerrit.server.config.GitWebCgiConfig; import com.google.gerrit.server.config.GitWebConfig; import com.google.gerrit.server.config.SitePaths; import com.google.gerrit.server.git.LocalDiskRepositoryManager; @@ -105,13 +106,14 @@ class GitWebServlet extends HttpServlet { SitePaths site, @GerritServerConfig Config cfg, SshInfo sshInfo, - GitWebConfig gitWebConfig) + GitWebConfig gitWebConfig, + GitWebCgiConfig gitWebCgiConfig) throws IOException { this.repoManager = repoManager; this.projectControl = projectControl; this.anonymousUserProvider = anonymousUserProvider; this.userProvider = userProvider; - this.gitwebCgi = gitWebConfig.getGitwebCGI(); + this.gitwebCgi = gitWebCgiConfig.getGitwebCgi(); this.deniedActions = new HashSet<>(); final String url = gitWebConfig.getUrl(); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebCgiConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebCgiConfig.java new file mode 100644 index 0000000000..63834f1cec --- /dev/null +++ b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebCgiConfig.java @@ -0,0 +1,137 @@ +// Copyright (C) 2015 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.server.config; + +import static java.nio.file.Files.isExecutable; +import static java.nio.file.Files.isRegularFile; + +import com.google.inject.Inject; +import com.google.inject.Singleton; + +import org.eclipse.jgit.lib.Config; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.nio.file.Path; +import java.nio.file.Paths; + +@Singleton +public class GitWebCgiConfig { + private static final Logger log = + LoggerFactory.getLogger(GitWebCgiConfig.class); + + public GitWebCgiConfig disabled() { + return new GitWebCgiConfig(); + } + + private final Path cgi; + private final Path css; + private final Path js; + private final Path logoPng; + + @Inject + GitWebCgiConfig(SitePaths sitePaths, @GerritServerConfig Config cfg) { + if (GitWebConfig.isDisabled(cfg)) { + cgi = null; + css = null; + js = null; + logoPng = null; + return; + } + + String cfgCgi = cfg.getString("gitweb", null, "cgi"); + Path pkgCgi = Paths.get("/usr/lib/cgi-bin/gitweb.cgi"); + String[] resourcePaths = {"/usr/share/gitweb/static", "/usr/share/gitweb", + "/var/www/static", "/var/www"}; + Path cgi; + + if (cfgCgi != null) { + // Use the CGI script configured by the administrator, failing if it + // cannot be used as specified. + // + cgi = sitePaths.resolve(cfgCgi); + if (!isRegularFile(cgi)) { + throw new IllegalStateException("Cannot find gitweb.cgi: " + cgi); + } + if (!isExecutable(cgi)) { + throw new IllegalStateException("Cannot execute gitweb.cgi: " + cgi); + } + + if (!cgi.equals(pkgCgi)) { + // Assume the administrator pointed us to the distribution, + // which also has the corresponding CSS and logo file. + // + String absPath = cgi.getParent().toAbsolutePath().toString(); + resourcePaths = new String[] {absPath + "/static", absPath}; + } + + } else if (isRegularFile(pkgCgi) && isExecutable(pkgCgi)) { + // Use the OS packaged CGI. + // + log.debug("Assuming gitweb at " + pkgCgi); + cgi = pkgCgi; + + } else { + log.warn("gitweb not installed (no " + pkgCgi + " found)"); + cgi = null; + resourcePaths = new String[] {}; + } + + Path css = null; + Path js = null; + Path logo = null; + for (String path : resourcePaths) { + Path dir = Paths.get(path); + css = dir.resolve("gitweb.css"); + js = dir.resolve("gitweb.js"); + logo = dir.resolve("git-logo.png"); + if (isRegularFile(css) && isRegularFile(logo)) { + break; + } + } + + this.cgi = cgi; + this.css = css; + this.js = js; + this.logoPng = logo; + } + + private GitWebCgiConfig() { + this.cgi = null; + this.css = null; + this.js = null; + this.logoPng = null; + } + + /** @return local path to the CGI executable; null if we shouldn't execute. */ + public Path getGitwebCgi() { + return cgi; + } + + /** @return local path of the {@code gitweb.css} matching the CGI. */ + public Path getGitwebCss() { + return css; + } + + /** @return local path of the {@code gitweb.js} for the CGI. */ + public Path getGitwebJs() { + return js; + } + + /** @return local path of the {@code git-logo.png} for the CGI. */ + public Path getGitLogoPng() { + return logoPng; + } +} diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java index 00767a16e9..671fc7f0d5 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java @@ -14,8 +14,7 @@ package com.google.gerrit.server.config; -import static java.nio.file.Files.isExecutable; -import static java.nio.file.Files.isRegularFile; +import static com.google.common.base.MoreObjects.firstNonNull; import com.google.common.base.Strings; import com.google.gerrit.common.data.GitWebType; @@ -25,12 +24,14 @@ import org.eclipse.jgit.lib.Config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.nio.file.Path; -import java.nio.file.Paths; - public class GitWebConfig { private static final Logger log = LoggerFactory.getLogger(GitWebConfig.class); + public static boolean isDisabled(Config cfg) { + return isEmptyString(cfg, "gitweb", null, "url") + || isEmptyString(cfg, "gitweb", null, "cgi"); + } + private static boolean isEmptyString(Config cfg, String section, String subsection, String name) { // This is currently the only way to check for the empty string in a JGit @@ -40,27 +41,29 @@ public class GitWebConfig { } private final String url; - private final Path gitweb_cgi; - private final Path gitweb_css; - private final Path gitweb_js; - private final Path git_logo_png; - private GitWebType type; + private final GitWebType type; @Inject - GitWebConfig(final SitePaths sitePaths, @GerritServerConfig final Config cfg) { - final String cfgUrl = cfg.getString("gitweb", null, "url"); - final String cfgCgi = cfg.getString("gitweb", null, "cgi"); - - type = GitWebType.fromName(cfg.getString("gitweb", null, "type")); - if (type == null) { + GitWebConfig(GitWebCgiConfig cgiConfig, @GerritServerConfig Config cfg) { + if (isDisabled(cfg)) { + type = null; url = null; - gitweb_cgi = null; - gitweb_css = null; - gitweb_js = null; - git_logo_png = null; return; } + String cfgUrl = cfg.getString("gitweb", null, "url"); + GitWebType type = GitWebType.fromName(cfg.getString("gitweb", null, "type")); + if (type == null) { + this.type = null; + url = null; + return; + } else if (cgiConfig.getGitwebCgi() == null) { + // Use an externally managed gitweb instance, and not an internal one. + url = cfgUrl; + } else { + url = firstNonNull(cfgUrl, "gitweb"); + } + type.setLinkName(cfg.getString("gitweb", null, "linkname")); type.setBranch(cfg.getString("gitweb", null, "branch")); type.setProject(cfg.getString("gitweb", null, "project")); @@ -86,107 +89,25 @@ public class GitWebConfig { if (type.getBranch() == null) { log.warn("No Pattern specified for gitweb.branch, disabling."); - type = null; + this.type = null; } else if (type.getProject() == null) { log.warn("No Pattern specified for gitweb.project, disabling."); - type = null; + this.type = null; } else if (type.getRevision() == null) { log.warn("No Pattern specified for gitweb.revision, disabling."); - type = null; + this.type = null; } else if (type.getRootTree() == null) { log.warn("No Pattern specified for gitweb.roottree, disabling."); - type = null; + this.type = null; } else if (type.getFile() == null) { log.warn("No Pattern specified for gitweb.file, disabling."); - type = null; + this.type = null; } else if (type.getFileHistory() == null) { log.warn("No Pattern specified for gitweb.filehistory, disabling."); - type = null; - } - - if (isEmptyString(cfg, "gitweb", null, "url") - || isEmptyString(cfg, "gitweb", null, "cgi")) { - // Either setting was explicitly set to the empty string disabling - // gitweb for this server. Disable the configuration. - // - url = null; - gitweb_cgi = null; - gitweb_css = null; - gitweb_js = null; - git_logo_png = null; - return; - } - - if ((cfgUrl != null) && (cfgCgi == null || cfgCgi.isEmpty())) { - // Use an externally managed gitweb instance, and not an internal one. - // - url = cfgUrl; - gitweb_cgi = null; - gitweb_css = null; - gitweb_js = null; - git_logo_png = null; - return; - } - - final Path pkgCgi = Paths.get("/usr/lib/cgi-bin/gitweb.cgi"); - String[] resourcePaths = {"/usr/share/gitweb/static", "/usr/share/gitweb", - "/var/www/static", "/var/www"}; - Path cgi; - - if (cfgCgi != null) { - // Use the CGI script configured by the administrator, failing if it - // cannot be used as specified. - // - cgi = sitePaths.resolve(cfgCgi); - if (!isRegularFile(cgi)) { - throw new IllegalStateException("Cannot find gitweb.cgi: " + cgi); - } - if (!isExecutable(cgi)) { - throw new IllegalStateException("Cannot execute gitweb.cgi: " + cgi); - } - - if (!cgi.equals(pkgCgi)) { - // Assume the administrator pointed us to the distribution, - // which also has the corresponding CSS and logo file. - // - String absPath = cgi.getParent().toAbsolutePath().toString(); - resourcePaths = new String[] {absPath + "/static", absPath}; - } - - } else if (isRegularFile(pkgCgi) && isExecutable(pkgCgi)) { - // Use the OS packaged CGI. - // - log.debug("Assuming gitweb at " + pkgCgi); - cgi = pkgCgi; - + this.type = null; } else { - log.warn("gitweb not installed (no " + pkgCgi + " found)"); - cgi = null; - resourcePaths = new String[] {}; + this.type = type; } - - Path css = null; - Path js = null; - Path logo = null; - for (String path : resourcePaths) { - Path dir = Paths.get(path); - css = dir.resolve("gitweb.css"); - js = dir.resolve("gitweb.js"); - logo = dir.resolve("git-logo.png"); - if (isRegularFile(css) && isRegularFile(logo)) { - break; - } - } - - if (cfgUrl == null || cfgUrl.isEmpty()) { - url = cgi != null ? "gitweb" : null; - } else { - url = cgi != null ? cfgUrl : null; - } - gitweb_cgi = cgi; - gitweb_css = css; - gitweb_js = js; - git_logo_png = logo; } /** @return GitWebType for gitweb viewer. */ @@ -203,26 +124,6 @@ public class GitWebConfig { return url; } - /** @return local path to the CGI executable; null if we shouldn't execute. */ - public Path getGitwebCGI() { - return gitweb_cgi; - } - - /** @return local path of the {@code gitweb.css} matching the CGI. */ - public Path getGitwebCSS() { - return gitweb_css; - } - - /** @return local path of the {@code gitweb.js} for the CGI. */ - public Path getGitwebJS() { - return gitweb_js; - } - - /** @return local path of the {@code git-logo.png} for the CGI. */ - public Path getGitLogoPNG() { - return git_logo_png; - } - /** * Determines if a given character can be used unencoded in an URL as a * replacement for the path separator '/'. From 62c78638ecf327ff5525a9df163e80e459bf6174 Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Fri, 5 Jun 2015 14:32:16 -0700 Subject: [PATCH 3/5] Move logic from GitWebType to GitWebConfig GitWebType is a dumb POJO. Initialization of this type was split across GitWebType and GitWebConfig for no strong reason, possibly related to the fact that GitWebType is in the gerrit-common package and so can't depend on the JGit Config object. The setters of GitWebType weren't behaving like normal POJO setters, as they were ignoring null or empty values. Get rid of this special-casing behavior, which made the behavior of GitWebConfig difficult to understand. Instead, move all the construction of a GitWebType to GitWebConfig, which is a server-side class and can handle the Config parsing as well as the named default configurations. Change-Id: I119778c3ab3b791fbf363e2d87818e40dc9687b6 --- .../google/gerrit/common/data/GitWebType.java | 83 +++-------- .../common/data/EncodePathSeparatorTest.java | 10 +- .../gerrit/server/config/GitWebConfig.java | 136 ++++++++++++++---- 3 files changed, 126 insertions(+), 103 deletions(-) diff --git a/gerrit-common/src/main/java/com/google/gerrit/common/data/GitWebType.java b/gerrit-common/src/main/java/com/google/gerrit/common/data/GitWebType.java index 0aff53941a..29d2ee4015 100644 --- a/gerrit-common/src/main/java/com/google/gerrit/common/data/GitWebType.java +++ b/gerrit-common/src/main/java/com/google/gerrit/common/data/GitWebType.java @@ -16,44 +16,6 @@ package com.google.gerrit.common.data; /** Class to store information about different gitweb types. */ public class GitWebType { - /** - * Get a GitWebType based on the given name. - * - * @param name Name to look for. - * @return GitWebType from the given name, else null if not found. - */ - public static GitWebType fromName(final String name) { - final GitWebType type; - - if (name == null || name.isEmpty() || name.equalsIgnoreCase("gitweb")) { - type = new GitWebType(); - type.setLinkName("gitweb"); - type.setProject("?p=${project}.git;a=summary"); - type.setRevision("?p=${project}.git;a=commit;h=${commit}"); - type.setBranch("?p=${project}.git;a=shortlog;h=${branch}"); - type.setRootTree("?p=${project}.git;a=tree;hb=${commit}"); - type.setFile("?p=${project}.git;hb=${commit};f=${file}"); - type.setFileHistory("?p=${project}.git;a=history;hb=${branch};f=${file}"); - } else if (name.equalsIgnoreCase("cgit")) { - type = new GitWebType(); - type.setLinkName("cgit"); - type.setProject("${project}.git/summary"); - type.setRevision("${project}.git/commit/?id=${commit}"); - type.setBranch("${project}.git/log/?h=${branch}"); - type.setRootTree("${project}.git/tree/?h=${commit}"); - type.setFile("${project}.git/tree/${file}?h=${commit}"); - type.setFileHistory("${project}.git/log/${file}?h=${branch}"); - } else if (name.equalsIgnoreCase("custom")) { - type = new GitWebType(); - // The custom name is not defined, let's keep the old style of using GitWeb - type.setLinkName("gitweb"); - } else { - type = null; - } - - return type; - } - /** name of the type. */ private String name; @@ -80,14 +42,10 @@ public class GitWebType { private char pathSeparator = '/'; /** Whether to include links to draft patch sets */ - private boolean linkDrafts; + private boolean linkDrafts = true; /** Whether to encode URL segments */ - private boolean urlEncode; - - /** Private default constructor for gson. */ - protected GitWebType() { - } + private boolean urlEncode = true; /** * Get the String for branch view. @@ -152,6 +110,15 @@ public class GitWebType { return fileHistory; } + /** + * Get the path separator used for branch and project names. + * + * @return The path separator. + */ + public char getPathSeparator() { + return pathSeparator; + } + /** * Get whether to link to draft patch sets * @@ -167,9 +134,7 @@ public class GitWebType { * @param pattern The pattern for branch view */ public void setBranch(final String pattern) { - if (pattern != null && !pattern.isEmpty()) { - branch = pattern; - } + branch = pattern; } /** @@ -178,9 +143,7 @@ public class GitWebType { * @param name The link-name type */ public void setLinkName(final String name) { - if (name != null && !name.isEmpty()) { - this.name = name; - } + this.name = name; } /** @@ -189,9 +152,7 @@ public class GitWebType { * @param pattern The pattern for project view */ public void setProject(final String pattern) { - if (pattern != null && !pattern.isEmpty()) { - project = pattern; - } + project = pattern; } /** @@ -200,9 +161,7 @@ public class GitWebType { * @param pattern The pattern for revision view */ public void setRevision(final String pattern) { - if (pattern != null && !pattern.isEmpty()) { - revision = pattern; - } + revision = pattern; } /** @@ -211,9 +170,7 @@ public class GitWebType { * @param pattern The pattern for root tree view */ public void setRootTree(final String pattern) { - if (pattern != null && !pattern.isEmpty()) { - rootTree = pattern; - } + rootTree = pattern; } /** @@ -222,9 +179,7 @@ public class GitWebType { * @param pattern The pattern for file view */ public void setFile(final String pattern) { - if (pattern != null && !pattern.isEmpty()) { - file = pattern; - } + file = pattern; } /** @@ -233,9 +188,7 @@ public class GitWebType { * @param pattern The pattern for file history view */ public void setFileHistory(final String pattern) { - if (pattern != null && !pattern.isEmpty()) { - fileHistory = pattern; - } + fileHistory = pattern; } /** diff --git a/gerrit-common/src/test/java/com/google/gerrit/common/data/EncodePathSeparatorTest.java b/gerrit-common/src/test/java/com/google/gerrit/common/data/EncodePathSeparatorTest.java index 816f715df9..8312a9c2e2 100644 --- a/gerrit-common/src/test/java/com/google/gerrit/common/data/EncodePathSeparatorTest.java +++ b/gerrit-common/src/test/java/com/google/gerrit/common/data/EncodePathSeparatorTest.java @@ -19,21 +19,15 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; public class EncodePathSeparatorTest { - @Test public void testDefaultBehaviour() { - - GitWebType gitWebType = GitWebType.fromName(null); - - assertEquals("a/b", gitWebType.replacePathSeparator("a/b")); + assertEquals("a/b", new GitWebType().replacePathSeparator("a/b")); } @Test public void testExclamationMark() { - - GitWebType gitWebType = GitWebType.fromName(null); + GitWebType gitWebType = new GitWebType(); gitWebType.setPathSeparator('!'); - assertEquals("a!b", gitWebType.replacePathSeparator("a/b")); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java index 671fc7f0d5..586d1924d6 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java @@ -15,6 +15,8 @@ package com.google.gerrit.server.config; import static com.google.common.base.MoreObjects.firstNonNull; +import static com.google.common.base.Strings.isNullOrEmpty; +import static com.google.common.base.Strings.nullToEmpty; import com.google.common.base.Strings; import com.google.gerrit.common.data.GitWebType; @@ -40,6 +42,103 @@ public class GitWebConfig { return values.length > 0 && Strings.isNullOrEmpty(values[0]); } + /** + * Get a GitWebType based on the given config. + * + * @param cfg Gerrit config. + * @return GitWebType from the given name, else null if not found. + */ + public static GitWebType typeFromConfig(Config cfg) { + GitWebType defaultType = defaultType(cfg.getString("gitweb", null, "type")); + if (defaultType == null) { + return null; + } + GitWebType type = new GitWebType(); + + type.setLinkName(firstNonNull( + cfg.getString("gitweb", null, "linkname"), + defaultType.getLinkName())); + type.setBranch(firstNonNull( + cfg.getString("gitweb", null, "branch"), + defaultType.getBranch())); + type.setProject(firstNonNull( + cfg.getString("gitweb", null, "project"), + defaultType.getProject())); + type.setRevision(firstNonNull( + cfg.getString("gitweb", null, "revision"), + defaultType.getRevision())); + type.setRootTree(firstNonNull( + cfg.getString("gitweb", null, "roottree"), + defaultType.getRootTree())); + type.setFile(firstNonNull( + cfg.getString("gitweb", null, "file"), + defaultType.getFile())); + type.setFileHistory(firstNonNull( + cfg.getString("gitweb", null, "filehistory"), + defaultType.getFileHistory())); + type.setLinkDrafts( + cfg.getBoolean("gitweb", null, "linkdrafts", + defaultType.getLinkDrafts())); + type.setUrlEncode( + cfg.getBoolean("gitweb", null, "urlencode", + defaultType.isUrlEncode())); + String pathSeparator = cfg.getString("gitweb", null, "pathSeparator"); + if (pathSeparator != null) { + if (pathSeparator.length() == 1) { + char c = pathSeparator.charAt(0); + if (isValidPathSeparator(c)) { + type.setPathSeparator( + firstNonNull(c, defaultType.getPathSeparator())); + } else { + log.warn("Invalid gitweb.pathSeparator: " + c); + } + } else { + log.warn( + "gitweb.pathSeparator is not a single character: " + pathSeparator); + } + } + return type; + } + + private static GitWebType defaultType(String typeName) { + GitWebType type = new GitWebType(); + switch (nullToEmpty(typeName)) { + case "": + case "gitweb": + type.setLinkName("gitweb"); + type.setProject("?p=${project}.git;a=summary"); + type.setRevision("?p=${project}.git;a=commit;h=${commit}"); + type.setBranch("?p=${project}.git;a=shortlog;h=${branch}"); + type.setRootTree("?p=${project}.git;a=tree;hb=${commit}"); + type.setFile("?p=${project}.git;hb=${commit};f=${file}"); + type.setFileHistory( + "?p=${project}.git;a=history;hb=${branch};f=${file}"); + break; + case "cgit": + type.setLinkName("cgit"); + type.setProject("${project}.git/summary"); + type.setRevision("${project}.git/commit/?id=${commit}"); + type.setBranch("${project}.git/log/?h=${branch}"); + type.setRootTree("${project}.git/tree/?h=${commit}"); + type.setFile("${project}.git/tree/${file}?h=${commit}"); + type.setFileHistory("${project}.git/log/${file}?h=${branch}"); + break; + case "custom": + // For a custom type with no explicit link name, just reuse "gitweb". + type.setLinkName("gitweb"); + type.setProject(""); + type.setRevision(""); + type.setBranch(""); + type.setRootTree(""); + type.setFile(""); + type.setFileHistory(""); + break; + default: + return null; + } + return type; + } + private final String url; private final GitWebType type; @@ -52,7 +151,7 @@ public class GitWebConfig { } String cfgUrl = cfg.getString("gitweb", null, "url"); - GitWebType type = GitWebType.fromName(cfg.getString("gitweb", null, "type")); + GitWebType type = typeFromConfig(cfg); if (type == null) { this.type = null; url = null; @@ -64,45 +163,22 @@ public class GitWebConfig { url = firstNonNull(cfgUrl, "gitweb"); } - type.setLinkName(cfg.getString("gitweb", null, "linkname")); - type.setBranch(cfg.getString("gitweb", null, "branch")); - type.setProject(cfg.getString("gitweb", null, "project")); - type.setRevision(cfg.getString("gitweb", null, "revision")); - type.setRootTree(cfg.getString("gitweb", null, "roottree")); - type.setFile(cfg.getString("gitweb", null, "file")); - type.setFileHistory(cfg.getString("gitweb", null, "filehistory")); - type.setLinkDrafts(cfg.getBoolean("gitweb", null, "linkdrafts", true)); - type.setUrlEncode(cfg.getBoolean("gitweb", null, "urlencode", true)); - String pathSeparator = cfg.getString("gitweb", null, "pathSeparator"); - if (pathSeparator != null) { - if (pathSeparator.length() == 1) { - char c = pathSeparator.charAt(0); - if (isValidPathSeparator(c)) { - type.setPathSeparator(c); - } else { - log.warn("Invalid value specified for gitweb.pathSeparator: " + c); - } - } else { - log.warn("Value specified for gitweb.pathSeparator is not a single character:" + pathSeparator); - } - } - - if (type.getBranch() == null) { + if (isNullOrEmpty(type.getBranch())) { log.warn("No Pattern specified for gitweb.branch, disabling."); this.type = null; - } else if (type.getProject() == null) { + } else if (isNullOrEmpty(type.getProject())) { log.warn("No Pattern specified for gitweb.project, disabling."); this.type = null; - } else if (type.getRevision() == null) { + } else if (isNullOrEmpty(type.getRevision())) { log.warn("No Pattern specified for gitweb.revision, disabling."); this.type = null; - } else if (type.getRootTree() == null) { + } else if (isNullOrEmpty(type.getRootTree())) { log.warn("No Pattern specified for gitweb.roottree, disabling."); this.type = null; - } else if (type.getFile() == null) { + } else if (isNullOrEmpty(type.getFile())) { log.warn("No Pattern specified for gitweb.file, disabling."); this.type = null; - } else if (type.getFileHistory() == null) { + } else if (isNullOrEmpty(type.getFileHistory())) { log.warn("No Pattern specified for gitweb.filehistory, disabling."); this.type = null; } else { From 2615c383776be79feb054f544b9b5ebbff2deea9 Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Fri, 5 Jun 2015 15:10:08 -0700 Subject: [PATCH 4/5] GitWebConfig: Minor cleanup Rearrange methods and fields to be consistent. Rewrite Javadoc to be consistent and ever so slightly less stuttery. Rename a method to be consistent. Change-Id: I81ca40ce36d85148d64fbbcef2bec97108662672 --- .../google/gerrit/common/data/GitWebType.java | 244 ++++++++---------- .../gerrit/server/config/GitWebConfig.java | 2 +- 2 files changed, 102 insertions(+), 144 deletions(-) diff --git a/gerrit-common/src/main/java/com/google/gerrit/common/data/GitWebType.java b/gerrit-common/src/main/java/com/google/gerrit/common/data/GitWebType.java index 29d2ee4015..5bf1dac855 100644 --- a/gerrit-common/src/main/java/com/google/gerrit/common/data/GitWebType.java +++ b/gerrit-common/src/main/java/com/google/gerrit/common/data/GitWebType.java @@ -14,190 +14,168 @@ package com.google.gerrit.common.data; -/** Class to store information about different gitweb types. */ +/** Class to store information about different source browser types. */ public class GitWebType { - /** name of the type. */ private String name; - /** String for revision view url. */ - private String revision; - - /** ParameterizedString for project view url. */ - private String project; - - /** ParameterizedString for branch view url. */ private String branch; - - /** ParameterizedString for root tree view url. */ + private String file; + private String fileHistory; + private String project; + private String revision; private String rootTree; - /** ParameterizedString for file view url. */ - private String file; - - /** ParameterizedString for file history view url. */ - private String fileHistory; - - /** Character to substitute the standard path separator '/' in branch and - * project names */ private char pathSeparator = '/'; - - /** Whether to include links to draft patch sets */ private boolean linkDrafts = true; - - /** Whether to encode URL segments */ private boolean urlEncode = true; - /** - * Get the String for branch view. - * - * @return The String for branch view - */ - public String getBranch() { - return branch; - } - - /** - * Get the String for link-name of the type. - * - * @return The String for link-name of the type - */ + /** @return name displayed in links. */ public String getLinkName() { return name; } /** - * Get the String for project view. + * Set the name displayed in links. * - * @return The String for project view + * @param name new name. */ - public String getProject() { - return project; + public void setLinkName(String name) { + this.name = name; + } + + /** @return parameterized string for the branch URL. */ + public String getBranch() { + return branch; } /** - * Get the String for revision view. + * Set the parameterized string for the branch URL. * - * @return The String for revision view + * @param str new string. */ - public String getRevision() { - return revision; + public void setBranch(String str) { + branch = str; } - /** - * Get the String for root tree view. - * - * @return The String for root tree view - */ - public String getRootTree() { - return rootTree; - } - - /** - * Get the String for file view. - * - * @return The String for file view - */ + /** @return parameterized string for the file URL. */ public String getFile() { return file; } /** - * Get the String for file history view. + * Set the parameterized string for the file URL. * - * @return The String for file history view + * @param str new string. */ + public void setFile(String str) { + file = str; + } + + /** @return parameterized string for the file history URL. */ public String getFileHistory() { return fileHistory; } /** - * Get the path separator used for branch and project names. + * Set the parameterized string for the file history URL. * - * @return The path separator. + * @param str new string. */ + public void setFileHistory(String str) { + fileHistory = str; + } + + /** @return parameterized string for the project URL. */ + public String getProject() { + return project; + } + + /** + * Set the parameterized string for the project URL. + * + * @param str new string. + */ + public void setProject(String str) { + project = str; + } + + /** @return parameterized string for the revision URL. */ + public String getRevision() { + return revision; + } + + /** + * Set the parameterized string for the revision URL. + * + * @param str new string. + */ + public void setRevision(String str) { + revision = str; + } + + /** @return parameterized string for the root tree URL. */ + public String getRootTree() { + return rootTree; + } + + /** + * Set the parameterized string for the root tree URL. + * + * @param str new string. + */ + public void setRootTree(String str) { + rootTree = str; + } + + /** @return path separator used for branch and project names. */ public char getPathSeparator() { return pathSeparator; } /** - * Get whether to link to draft patch sets + * Set the custom path separator. * - * @return True to link + * @param separator new separator. */ + public void setPathSeparator(char separator) { + this.pathSeparator = separator; + } + + /** @return whether to generate links to draft patch sets. */ public boolean getLinkDrafts() { return linkDrafts; } /** - * Set the pattern for branch view. + * Set whether to generate links to draft patch sets. * - * @param pattern The pattern for branch view + * @param linkDrafts new value. */ - public void setBranch(final String pattern) { - branch = pattern; + public void setLinkDrafts(boolean linkDrafts) { + this.linkDrafts = linkDrafts; + } + + /** @return whether to URL encode path segments. */ + public boolean getUrlEncode() { + return urlEncode; } /** - * Set the pattern for link-name type. + * Set whether to URL encode path segments. * - * @param name The link-name type + * @param urlEncode new value. */ - public void setLinkName(final String name) { - this.name = name; + public void setUrlEncode(boolean urlEncode) { + this.urlEncode = urlEncode; } /** - * Set the pattern for project view. + * Replace standard path separator with custom configured path separator. * - * @param pattern The pattern for project view - */ - public void setProject(final String pattern) { - project = pattern; - } - - /** - * Set the pattern for revision view. - * - * @param pattern The pattern for revision view - */ - public void setRevision(final String pattern) { - revision = pattern; - } - - /** - * Set the pattern for root tree view. - * - * @param pattern The pattern for root tree view - */ - public void setRootTree(final String pattern) { - rootTree = pattern; - } - - /** - * Set the pattern for file view. - * - * @param pattern The pattern for file view - */ - public void setFile(final String pattern) { - file = pattern; - } - - /** - * Set the pattern for file history view. - * - * @param pattern The pattern for file history view - */ - public void setFileHistory(final String pattern) { - fileHistory = pattern; - } - - /** - * Replace the standard path separator ('/') in a branch name or project - * name with a custom path separator configured by the property - * gitweb.pathSeparator. - * @param urlSegment The branch or project to replace the path separator in - * @return the urlSegment with the standard path separator replaced by the - * custom path separator + * @param urlSegment URL segment (e.g. branch or project name) in which to + * replace the path separator. + * @return the segment with the standard path separator replaced by the custom + * {@link #getPathSeparator()}. */ public String replacePathSeparator(String urlSegment) { if ('/' != pathSeparator) { @@ -205,24 +183,4 @@ public class GitWebType { } return urlSegment; } - - /** - * Set the custom path separator - * @param separator The custom path separator - */ - public void setPathSeparator(char separator) { - this.pathSeparator = separator; - } - - public void setLinkDrafts(boolean linkDrafts) { - this.linkDrafts = linkDrafts; - } - - public boolean isUrlEncode() { - return urlEncode; - } - - public void setUrlEncode(boolean urlEncode) { - this.urlEncode = urlEncode; - } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java index 586d1924d6..c1fee2d852 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java @@ -81,7 +81,7 @@ public class GitWebConfig { defaultType.getLinkDrafts())); type.setUrlEncode( cfg.getBoolean("gitweb", null, "urlencode", - defaultType.isUrlEncode())); + defaultType.getUrlEncode())); String pathSeparator = cfg.getString("gitweb", null, "pathSeparator"); if (pathSeparator != null) { if (pathSeparator.length() == 1) { From a3d67882125065c86ae55ccbb45e36d2ca6e453e Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Fri, 5 Jun 2015 15:22:23 -0700 Subject: [PATCH 5/5] Use consistent lowercase for "gitweb" We had inconsistent class and variable naming in Gerrit to the point that (prior to I640e645f6) there were two completely different classes named "GitwebConfig" and "GitWebConfig". In the official upstream Git documentation, this command line tool is most often referred to as "gitweb". Standardize on this capitalization in text. It may still be capitalized at the beginning of sentences, or where required by programming language style (e.g. Java class names). The only exceptions are: - MSysGit's wiki page is entitled GitWeb, so use that when referring specifically to that page. - Old release notes were not touched. Change-Id: I497477c264e9cc1380c520618f8edf13e7226c9d --- Documentation/config-gerrit.txt | 2 +- Documentation/config-gitweb.txt | 12 +++--- Documentation/config-plugins.txt | 2 +- Documentation/intro-project-owner.txt | 2 +- Documentation/rest-api-config.txt | 42 +++++++++---------- Documentation/user-review-ui.txt | 2 +- .../acceptance/rest/config/ServerInfoIT.java | 4 +- .../data/{GitWebType.java => GitwebType.java} | 2 +- .../common/data/EncodePathSeparatorTest.java | 8 ++-- .../client/admin/ProjectAccessEditor.java | 4 +- .../client/admin/ProjectBranchesScreen.java | 4 +- .../client/admin/ProjectListScreen.java | 12 +++--- .../gerrit/client/change/CommitBox.java | 6 +-- .../client/change/RelatedChangesTab.java | 6 +-- .../{GitWebInfo.java => GitwebInfo.java} | 34 +++++++-------- ...itWebTypeInfo.java => GitwebTypeInfo.java} | 4 +- .../gerrit/client/config/ServerInfo.java | 2 +- .../com/google/gerrit/client/diff/Header.java | 8 ++-- .../com/google/gerrit/httpd/WebModule.java | 14 +++---- .../gerrit/httpd/gitweb/GitLogoServlet.java | 4 +- ...bCssServlet.java => GitwebCssServlet.java} | 12 +++--- ...vlet.java => GitwebJavaScriptServlet.java} | 8 ++-- .../{GitWebModule.java => GitwebModule.java} | 10 ++--- ...{GitWebServlet.java => GitwebServlet.java} | 26 ++++++------ .../server/config/GerritGlobalModule.java | 2 +- .../gerrit/server/config/GetServerInfo.java | 24 +++++------ ...WebCgiConfig.java => GitwebCgiConfig.java} | 14 +++---- .../{GitWebConfig.java => GitwebConfig.java} | 30 ++++++------- ...bConfigTest.java => GitwebConfigTest.java} | 8 ++-- 29 files changed, 153 insertions(+), 155 deletions(-) rename gerrit-common/src/main/java/com/google/gerrit/common/data/{GitWebType.java => GitwebType.java} (99%) rename gerrit-gwtui/src/main/java/com/google/gerrit/client/config/{GitWebInfo.java => GitwebInfo.java} (86%) rename gerrit-gwtui/src/main/java/com/google/gerrit/client/config/{GitWebTypeInfo.java => GitwebTypeInfo.java} (95%) rename gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/{GitWebCssServlet.java => GitwebCssServlet.java} (91%) rename gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/{GitWebJavaScriptServlet.java => GitwebJavaScriptServlet.java} (91%) rename gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/{GitWebModule.java => GitwebModule.java} (74%) rename gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/{GitWebServlet.java => GitwebServlet.java} (97%) rename gerrit-server/src/main/java/com/google/gerrit/server/config/{GitWebCgiConfig.java => GitwebCgiConfig.java} (92%) rename gerrit-server/src/main/java/com/google/gerrit/server/config/{GitWebConfig.java => GitwebConfig.java} (90%) rename gerrit-server/src/test/java/com/google/gerrit/server/config/{GitWebConfigTest.java => GitwebConfigTest.java} (84%) diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt index f8a4159ad8..c94da7c40c 100644 --- a/Documentation/config-gerrit.txt +++ b/Documentation/config-gerrit.txt @@ -1763,7 +1763,7 @@ Whether or not Gerrit should encode the generated viewer URL. + Gerrit composes the viewer URL using information about the project, branch, file or commit of the target object to be displayed. Typically viewers such as CGit -and GitWeb do need those parts to be encoded, including the '/' in project's name, +and gitweb do need those parts to be encoded, including the '/' in project's name, for being correctly parsed. However other viewers could instead require an unencoded URL (e.g. GitHub web based viewer) diff --git a/Documentation/config-gitweb.txt b/Documentation/config-gitweb.txt index 23111844aa..0fbb7ee828 100644 --- a/Documentation/config-gitweb.txt +++ b/Documentation/config-gitweb.txt @@ -67,12 +67,12 @@ able to read the gitweb info for any of the branches in that project. For the external configuration, gitweb runs under the control of an external web server, and Gerrit access controls are not enforced. Gerrit -provides configuration parameters for integration with GitWeb. +provides configuration parameters for integration with gitweb. [[linuxGitWeb]] ==== Linux Installation -===== Install GitWeb +===== Install Gitweb On Ubuntu: @@ -86,7 +86,7 @@ With Yum: $ yum install gitweb ==== -===== Configure GitWeb +===== Configure Gitweb Update `/etc/gitweb.conf`, add the public GIT repositories: @@ -161,7 +161,7 @@ link:http://localhost/gitweb[http://localhost/gitweb] [[WindowsGitWeb]] ==== Windows Installation -Instructions are available for installing the GitWeb module distributed with +Instructions are available for installing the gitweb module distributed with MsysGit: link:https://github.com/msysgit/msysgit/wiki/GitWeb[GitWeb] @@ -176,7 +176,7 @@ If you're still having difficulty setting up permissions, you may find this tech note useful for configuring Apache Service to run under another account. You must grant the new account link:http://technet.microsoft.com/en-us/library/cc794944(WS.10).aspx["run as service"] permission: -The GitWeb version in msysgit is missing several important and required +The gitweb version in msysgit is missing several important and required perl modules, including CGI.pm. The perl included with the msysgit distro 1.7.8 is broken.. The link:http://groups.google.com/group/msysgit/browse_thread/thread/ba3501f1f0ed95af[unicore folder is missing along with utf8_heavy.pl and CGI.pm]. You can verify by checking for perl modules. From an msys console, execute the @@ -207,7 +207,7 @@ contents: `bin/` `lib/` `site/` copy the contents of lib into `msysgit/lib/perl5/5.8.8` and overwrite existing files. -==== Enable GitWeb Integration +==== Enable Gitweb Integration To enable the external gitweb integration, set link:config-gerrit.html#gitweb.url[gitweb.url] with the URL of your diff --git a/Documentation/config-plugins.txt b/Documentation/config-plugins.txt index b0bf921152..39332d792c 100644 --- a/Documentation/config-plugins.txt +++ b/Documentation/config-plugins.txt @@ -166,7 +166,7 @@ Project] This plugin allows the rendering of Git repository branch network in a graphical HTML5 Canvas. It is mainly intended to be used as a -"project link" in a GitWeb configuration or by other Gerrit GWT UI +"project link" in a gitweb configuration or by other Gerrit GWT UI plugins to be plugged elsewhere in Gerrit. link:https://gerrit-review.googlesource.com/#/admin/projects/plugins/branch-network[ diff --git a/Documentation/intro-project-owner.txt b/Documentation/intro-project-owner.txt index eb3c4fb5a2..dfffe57fd7 100644 --- a/Documentation/intro-project-owner.txt +++ b/Documentation/intro-project-owner.txt @@ -63,7 +63,7 @@ always see how the access rights were changed and by whom. If a good commit message is provided you can also see from the history why the access rights were modified. -If a Git browser such as GitWeb is configured for the Gerrit server you +If a Git browser such as gitweb is configured for the Gerrit server you can find a link to the history of the `project.config` file in the Web UI. Otherwise you may inspect the history locally. If you have cloned the repository you can do this by executing the following diff --git a/Documentation/rest-api-config.txt b/Documentation/rest-api-config.txt index df634fadb1..d8a6dba5df 100644 --- a/Documentation/rest-api-config.txt +++ b/Documentation/rest-api-config.txt @@ -1165,48 +1165,48 @@ bugs link]. |================================= [[git-web-info]] -=== GitWebInfo -The `GitWebInfo` entity contains information about the -link:config-gerrit.html#gitweb[GitWeb] configuration. +=== GitwebInfo +The `GitwebInfo` entity contains information about the +link:config-gerrit.html#gitweb[gitweb] configuration. [options="header",cols="1,6"] |======================= |Field Name |Description |`url` | -The link:config-gerrit.html#gitweb.url[GitWeb base URL]. +The link:config-gerrit.html#gitweb.url[gitweb base URL]. |`type` | -The link:config-gerrit.html#gitweb.type[GitWeb type] as -link:#git-web-type-info[GitWebTypeInfo] entity. +The link:config-gerrit.html#gitweb.type[gitweb type] as +link:#git-web-type-info[GitwebTypeInfo] entity. |======================= [[git-web-type-info]] -=== GitWebTypeInfo -The `GitWebTypeInfo` entity contains information about the -link:config-gerrit.html#gitweb[GitWeb] configuration. +=== GitwebTypeInfo +The `GitwebTypeInfo` entity contains information about the +link:config-gerrit.html#gitweb[gitweb] configuration. [options="header",cols="1,^1,5"] |============================= |Field Name ||Description |`name` || -The link:config-gerrit.html#gitweb.linkname[GitWeb link name]. +The link:config-gerrit.html#gitweb.linkname[gitweb link name]. |`revision` |optional| -The link:config-gerrit.html#gitweb.revision[GitWeb revision pattern]. +The link:config-gerrit.html#gitweb.revision[gitweb revision pattern]. |`project` |optional| -The link:config-gerrit.html#gitweb.project[GitWeb project pattern]. +The link:config-gerrit.html#gitweb.project[gitweb project pattern]. |`branch` |optional| -The link:config-gerrit.html#gitweb.branch[GitWeb branch pattern]. +The link:config-gerrit.html#gitweb.branch[gitweb branch pattern]. |`root_tree` |optional| -The link:config-gerrit.html#gitweb.roottree[GitWeb root tree pattern]. +The link:config-gerrit.html#gitweb.roottree[gitweb root tree pattern]. |`file` |optional| -The link:config-gerrit.html#gitweb.file[GitWeb file pattern]. +The link:config-gerrit.html#gitweb.file[gitweb file pattern]. |`file_history` |optional| -The link:config-gerrit.html#gitweb.filehistory[GitWeb file history +The link:config-gerrit.html#gitweb.filehistory[gitweb file history pattern]. |`path_separator`|| -The link:config-gerrit.html#gitweb.pathSeparator[GitWeb path separator]. +The link:config-gerrit.html#gitweb.pathSeparator[gitweb path separator]. |`link_drafts` |optional| link:config-gerrit.html#gitweb.linkDrafts[Whether Gerrit should provide -links to GitWeb on draft patch set.] +links to gitweb on draft patch set.] |`url_encode` |optional| link:config-gerrit.html#gitweb.urlEncode[Whether Gerrit should encode the generated viewer URL.] @@ -1300,9 +1300,9 @@ information about Gerrit Information about the configuration from the link:config-gerrit.html#gerrit[gerrit] section as link:#gerrit-info[ GerritInfo] entity. -|`git_web` |optional| -Information about the link:config-gerrit.html#gitweb[GitWeb] -configuration as link:#git-web-info[GitWebInfo] entity. +|`gitweb ` |optional| +Information about the link:config-gerrit.html#gitweb[gitweb] +configuration as link:#git-web-info[GitwebInfo] entity. |`sshd` |optional| Information about the configuration from the link:config-gerrit.html#sshd[sshd] section as link:#sshd-info[SshdInfo] diff --git a/Documentation/user-review-ui.txt b/Documentation/user-review-ui.txt index 13aed381aa..76220e0752 100644 --- a/Documentation/user-review-ui.txt +++ b/Documentation/user-review-ui.txt @@ -94,7 +94,7 @@ The commit ID, the parent commit(s) and the link:user-changeid.html[Change-Id] a displayed with a copy-to-clipboard icon that allows the ID to be copied into the clipboard. -If a Git web browser, such as GitWeb or Gitiles, is configured, there +If a Git web browser, such as gitweb or Gitiles, is configured, there is also a link to the commit in the Git web browser. image::images/user-review-ui-change-screen-commit-info.png[width=800, link="images/user-review-ui-change-screen-commit-info.png"] diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/config/ServerInfoIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/config/ServerInfoIT.java index 1fb0d0cc7f..f75780cc6c 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/config/ServerInfoIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/config/ServerInfoIT.java @@ -108,7 +108,7 @@ public class ServerInfoIT extends AbstractDaemonTest { assertThat(i.gerrit.reportBugText).isEqualTo("REPORT BUG"); // gitweb - assertThat(i.gitWeb).isNull(); + assertThat(i.gitweb).isNull(); // sshd assertThat(i.sshd).isNotNull(); @@ -161,7 +161,7 @@ public class ServerInfoIT extends AbstractDaemonTest { assertThat(i.gerrit.reportBugText).isNull(); // gitweb - assertThat(i.gitWeb).isNull(); + assertThat(i.gitweb).isNull(); // sshd assertThat(i.sshd).isNotNull(); diff --git a/gerrit-common/src/main/java/com/google/gerrit/common/data/GitWebType.java b/gerrit-common/src/main/java/com/google/gerrit/common/data/GitwebType.java similarity index 99% rename from gerrit-common/src/main/java/com/google/gerrit/common/data/GitWebType.java rename to gerrit-common/src/main/java/com/google/gerrit/common/data/GitwebType.java index 5bf1dac855..7cdec2fb11 100644 --- a/gerrit-common/src/main/java/com/google/gerrit/common/data/GitWebType.java +++ b/gerrit-common/src/main/java/com/google/gerrit/common/data/GitwebType.java @@ -15,7 +15,7 @@ package com.google.gerrit.common.data; /** Class to store information about different source browser types. */ -public class GitWebType { +public class GitwebType { private String name; private String branch; diff --git a/gerrit-common/src/test/java/com/google/gerrit/common/data/EncodePathSeparatorTest.java b/gerrit-common/src/test/java/com/google/gerrit/common/data/EncodePathSeparatorTest.java index 8312a9c2e2..ea3721ed08 100644 --- a/gerrit-common/src/test/java/com/google/gerrit/common/data/EncodePathSeparatorTest.java +++ b/gerrit-common/src/test/java/com/google/gerrit/common/data/EncodePathSeparatorTest.java @@ -21,14 +21,14 @@ import org.junit.Test; public class EncodePathSeparatorTest { @Test public void testDefaultBehaviour() { - assertEquals("a/b", new GitWebType().replacePathSeparator("a/b")); + assertEquals("a/b", new GitwebType().replacePathSeparator("a/b")); } @Test public void testExclamationMark() { - GitWebType gitWebType = new GitWebType(); - gitWebType.setPathSeparator('!'); - assertEquals("a!b", gitWebType.replacePathSeparator("a/b")); + GitwebType gitwebType = new GitwebType(); + gitwebType.setPathSeparator('!'); + assertEquals("a!b", gitwebType.replacePathSeparator("a/b")); } } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectAccessEditor.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectAccessEditor.java index 953f01ff68..7166c0f00f 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectAccessEditor.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectAccessEditor.java @@ -16,7 +16,7 @@ package com.google.gerrit.client.admin; import com.google.gerrit.client.Dispatcher; import com.google.gerrit.client.Gerrit; -import com.google.gerrit.client.config.GitWebInfo; +import com.google.gerrit.client.config.GitwebInfo; import com.google.gerrit.client.ui.Hyperlink; import com.google.gerrit.client.ui.ParentProjectBox; import com.google.gerrit.common.data.AccessSection; @@ -121,7 +121,7 @@ public class ProjectAccessEditor extends Composite implements inheritsFrom.getStyle().setDisplay(Display.NONE); } - GitWebInfo c = Gerrit.info().gitWeb(); + GitwebInfo c = Gerrit.info().gitweb(); if (value.isConfigVisible() && c != null) { history.getStyle().setDisplay(Display.BLOCK); gitweb.setText(c.getLinkName()); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectBranchesScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectBranchesScreen.java index 8cfda40de0..283c834305 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectBranchesScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectBranchesScreen.java @@ -26,7 +26,7 @@ import com.google.gerrit.client.access.AccessMap; import com.google.gerrit.client.access.ProjectAccessInfo; import com.google.gerrit.client.actions.ActionButton; import com.google.gerrit.client.actions.ActionInfo; -import com.google.gerrit.client.config.GitWebInfo; +import com.google.gerrit.client.config.GitwebInfo; import com.google.gerrit.client.projects.BranchInfo; import com.google.gerrit.client.projects.ProjectApi; import com.google.gerrit.client.rpc.GerritCallback; @@ -457,7 +457,7 @@ public class ProjectBranchesScreen extends ProjectScreen { } void populate(int row, BranchInfo k) { - GitWebInfo c = Gerrit.info().gitWeb(); + GitwebInfo c = Gerrit.info().gitweb(); if (k.canDelete()) { CheckBox sel = new CheckBox(); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectListScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectListScreen.java index 4fc0caf17f..2ee6c8543d 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectListScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectListScreen.java @@ -19,7 +19,7 @@ import static com.google.gerrit.common.PageLinks.ADMIN_PROJECTS; import com.google.gerrit.client.Dispatcher; import com.google.gerrit.client.Gerrit; import com.google.gerrit.client.WebLinkInfo; -import com.google.gerrit.client.config.GitWebInfo; +import com.google.gerrit.client.config.GitwebInfo; import com.google.gerrit.client.projects.ProjectInfo; import com.google.gerrit.client.projects.ProjectMap; import com.google.gerrit.client.rpc.GerritCallback; @@ -185,16 +185,16 @@ public class ProjectListScreen extends Screen { } private void addWebLinks(int row, ProjectInfo k) { - GitWebInfo gitWebLink = Gerrit.info().gitWeb(); + GitwebInfo gitwebLink = Gerrit.info().gitweb(); List webLinks = Natives.asList(k.webLinks()); - if (gitWebLink != null || (webLinks != null && !webLinks.isEmpty())) { + if (gitwebLink != null || (webLinks != null && !webLinks.isEmpty())) { FlowPanel p = new FlowPanel(); table.setWidget(row, ProjectsTable.C_REPO_BROWSER, p); - if (gitWebLink != null) { + if (gitwebLink != null) { Anchor a = new Anchor(); - a.setText(gitWebLink.getLinkName()); - a.setHref(gitWebLink.toProject(k.name_key())); + a.setText(gitwebLink.getLinkName()); + a.setHref(gitwebLink.toProject(k.name_key())); p.add(a); } if (webLinks != null) { diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.java index 27c440ea9c..68b230f37c 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.java @@ -23,7 +23,7 @@ import com.google.gerrit.client.changes.ChangeInfo; import com.google.gerrit.client.changes.ChangeInfo.CommitInfo; import com.google.gerrit.client.changes.ChangeInfo.GitPerson; import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo; -import com.google.gerrit.client.config.GitWebInfo; +import com.google.gerrit.client.config.GitwebInfo; import com.google.gerrit.client.rpc.Natives; import com.google.gerrit.client.ui.CommentLinkProcessor; import com.google.gerrit.client.ui.InlineHyperlink; @@ -135,7 +135,7 @@ class CommitBox extends Composite { private void setWebLinks(ChangeInfo change, String revision, RevisionInfo revInfo) { - GitWebInfo gw = Gerrit.info().gitWeb(); + GitwebInfo gw = Gerrit.info().gitweb(); if (gw != null && gw.canLink(revInfo)) { toAnchor(gw.toRevision(change.project(), revision), gw.getLinkName()); @@ -184,7 +184,7 @@ class CommitBox extends Composite { } private void addLinks(String project, CommitInfo c, FlowPanel panel) { - GitWebInfo gw = Gerrit.info().gitWeb(); + GitwebInfo gw = Gerrit.info().gitweb(); if (gw != null) { Anchor a = new Anchor(gw.getLinkName(), gw.toRevision(project, c.commit())); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/RelatedChangesTab.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/RelatedChangesTab.java index bd770349ca..b742a7f617 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/RelatedChangesTab.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/RelatedChangesTab.java @@ -18,7 +18,7 @@ import com.google.gerrit.client.Gerrit; import com.google.gerrit.client.change.RelatedChanges.ChangeAndCommit; import com.google.gerrit.client.changes.ChangeInfo.CommitInfo; import com.google.gerrit.client.changes.Util; -import com.google.gerrit.client.config.GitWebInfo; +import com.google.gerrit.client.config.GitwebInfo; import com.google.gerrit.common.PageLinks; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gwt.core.client.GWT; @@ -301,7 +301,7 @@ class RelatedChangesTab implements IsWidget { sb.closeSpan(); sb.openSpan(); - GitWebInfo gw = Gerrit.info().gitWeb(); + GitwebInfo gw = Gerrit.info().gitweb(); if (gw != null && (!info.hasChangeNumber() || !info.hasRevisionNumber())) { sb.setStyleName(RelatedChanges.R.css().gitweb()); sb.setAttribute("title", gw.getLinkName()); @@ -335,7 +335,7 @@ class RelatedChangesTab implements IsWidget { id.getId()); } - GitWebInfo gw = Gerrit.info().gitWeb(); + GitwebInfo gw = Gerrit.info().gitweb(); if (gw != null && project != null) { return gw.toRevision(project, info.commit().commit()); } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/config/GitWebInfo.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/config/GitwebInfo.java similarity index 86% rename from gerrit-gwtui/src/main/java/com/google/gerrit/client/config/GitWebInfo.java rename to gerrit-gwtui/src/main/java/com/google/gerrit/client/config/GitwebInfo.java index 3505c0896c..60b10e566c 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/config/GitWebInfo.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/config/GitwebInfo.java @@ -25,9 +25,9 @@ import com.google.gwt.http.client.URL; import java.util.HashMap; import java.util.Map; -public class GitWebInfo extends JavaScriptObject { +public class GitwebInfo extends JavaScriptObject { public final native String url() /*-{ return this.url; }-*/; - public final native GitWebTypeInfo type() /*-{ return this.type; }-*/; + public final native GitwebTypeInfo type() /*-{ return this.type; }-*/; /** * Checks whether the given patch set can be linked. @@ -56,20 +56,20 @@ public class GitWebInfo extends JavaScriptObject { } /** - * Returns the name for GitWeb links. + * Returns the name for gitweb links. * - * @return the name for GitWeb links + * @return the name for gitweb links */ public final String getLinkName() { return "(" + type().name() + ")"; } /** - * Returns the GitWeb link to a revision. + * Returns the gitweb link to a revision. * * @param project the name of the project * @param commit the commit ID - * @return GitWeb link to a revision + * @return gitweb link to a revision */ public final String toRevision(String project, String commit) { ParameterizedString pattern = new ParameterizedString(type().revision()); @@ -80,21 +80,21 @@ public class GitWebInfo extends JavaScriptObject { } /** - * Returns the GitWeb link to a revision. + * Returns the gitweb link to a revision. * * @param project the name of the project * @param ps the patch set - * @return GitWeb link to a revision + * @return gitweb link to a revision */ public final String toRevision(Project.NameKey project, PatchSet ps) { return toRevision(project.get(), ps.getRevision().get()); } /** - * Returns the GitWeb link to a project. + * Returns the gitweb link to a project. * * @param project the project name key - * @return GitWeb link to a project + * @return gitweb link to a project */ public final String toProject(Project.NameKey project) { ParameterizedString pattern = new ParameterizedString(type().project()); @@ -105,10 +105,10 @@ public class GitWebInfo extends JavaScriptObject { } /** - * Returns the GitWeb link to a branch. + * Returns the gitweb link to a branch. * * @param branch the branch name key - * @return GitWeb link to a branch + * @return gitweb link to a branch */ public final String toBranch(Branch.NameKey branch) { ParameterizedString pattern = new ParameterizedString(type().branch()); @@ -120,12 +120,12 @@ public class GitWebInfo extends JavaScriptObject { } /** - * Returns the GitWeb link to a file. + * Returns the gitweb link to a file. * * @param project the branch name key * @param commit the commit ID * @param file the path of the file - * @return GitWeb link to a file + * @return gitweb link to a file */ public final String toFile(String project, String commit, String file) { Map p = new HashMap<>(); @@ -140,11 +140,11 @@ public class GitWebInfo extends JavaScriptObject { } /** - * Returns the GitWeb link to a file history. + * Returns the gitweb link to a file history. * * @param branch the branch name key * @param file the path of the file - * @return GitWeb link to a file history + * @return gitweb link to a file history */ public final String toFileHistory(Branch.NameKey branch, String file) { ParameterizedString pattern = new ParameterizedString(type().fileHistory()); @@ -164,6 +164,6 @@ public class GitWebInfo extends JavaScriptObject { } } - protected GitWebInfo() { + protected GitwebInfo() { } } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/config/GitWebTypeInfo.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/config/GitwebTypeInfo.java similarity index 95% rename from gerrit-gwtui/src/main/java/com/google/gerrit/client/config/GitWebTypeInfo.java rename to gerrit-gwtui/src/main/java/com/google/gerrit/client/config/GitwebTypeInfo.java index 3deadc7ee3..ea2c6c0f1e 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/config/GitWebTypeInfo.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/config/GitwebTypeInfo.java @@ -16,7 +16,7 @@ package com.google.gerrit.client.config; import com.google.gwt.core.client.JavaScriptObject; -public class GitWebTypeInfo extends JavaScriptObject { +public class GitwebTypeInfo extends JavaScriptObject { /** * Replace the standard path separator ('/') in a branch name or project * name with a custom path separator configured by the property @@ -43,6 +43,6 @@ public class GitWebTypeInfo extends JavaScriptObject { public final native boolean linkDrafts() /*-{ return this.link_drafts || false; }-*/; public final native boolean urlEncode() /*-{ return this.url_encode || false; }-*/; - protected GitWebTypeInfo() { + protected GitwebTypeInfo() { } } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/config/ServerInfo.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/config/ServerInfo.java index 1183e4718d..72b1f4b255 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/config/ServerInfo.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/config/ServerInfo.java @@ -22,7 +22,7 @@ public class ServerInfo extends JavaScriptObject { public final native ContactStoreInfo contactStore() /*-{ return this.contact_store; }-*/; public final native DownloadInfo download() /*-{ return this.download; }-*/; public final native GerritInfo gerrit() /*-{ return this.gerrit; }-*/; - public final native GitWebInfo gitWeb() /*-{ return this.git_web; }-*/; + public final native GitwebInfo gitweb() /*-{ return this.gitweb; }-*/; public final native SshdInfo sshd() /*-{ return this.sshd; }-*/; public final native SuggestInfo suggest() /*-{ return this.suggest; }-*/; public final native UserConfigInfo user() /*-{ return this.user; }-*/; diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/Header.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/Header.java index 5e86b39406..799eee563b 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/Header.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/Header.java @@ -22,7 +22,7 @@ import com.google.gerrit.client.changes.ChangeInfo; import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo; import com.google.gerrit.client.changes.ReviewInfo; import com.google.gerrit.client.changes.Util; -import com.google.gerrit.client.config.GitWebInfo; +import com.google.gerrit.client.config.GitwebInfo; import com.google.gerrit.client.diff.DiffInfo.Region; import com.google.gerrit.client.patches.PatchUtil; import com.google.gerrit.client.rpc.CallbackGroup; @@ -115,8 +115,8 @@ public class Header extends Composite { return b.append(Util.C.commitMessage()); } - GitWebInfo gw = (project != null && commit != null) - ? Gerrit.info().gitWeb() : null; + GitwebInfo gw = (project != null && commit != null) + ? Gerrit.info().gitweb() : null; int s = path.lastIndexOf('/') + 1; if (gw != null && s > 0) { String base = path.substring(0, s - 1); @@ -193,7 +193,7 @@ public class Header extends Composite { } void setChangeInfo(ChangeInfo info) { - GitWebInfo gw = Gerrit.info().gitWeb(); + GitwebInfo gw = Gerrit.info().gitweb(); if (gw != null) { for (RevisionInfo rev : Natives.asList(info.revisions().values())) { if (patchSetId.getId().equals(rev.id())) { diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/WebModule.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/WebModule.java index d5f11004fa..9e425e965a 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/WebModule.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/WebModule.java @@ -23,14 +23,14 @@ import com.google.gerrit.httpd.auth.become.BecomeAnyAccountModule; import com.google.gerrit.httpd.auth.container.HttpAuthModule; import com.google.gerrit.httpd.auth.container.HttpsClientSslCertModule; import com.google.gerrit.httpd.auth.ldap.LdapAuthModule; -import com.google.gerrit.httpd.gitweb.GitWebModule; +import com.google.gerrit.httpd.gitweb.GitwebModule; import com.google.gerrit.httpd.rpc.UiRpcModule; import com.google.gerrit.lifecycle.LifecycleModule; import com.google.gerrit.server.RemotePeer; import com.google.gerrit.server.config.AuthConfig; import com.google.gerrit.server.config.CanonicalWebUrl; import com.google.gerrit.server.config.GerritRequestModule; -import com.google.gerrit.server.config.GitWebCgiConfig; +import com.google.gerrit.server.config.GitwebCgiConfig; import com.google.gerrit.server.git.AsyncReceiveCommits; import com.google.gerrit.server.util.GuiceRequestScopePropagator; import com.google.gerrit.server.util.RequestScopePropagator; @@ -43,18 +43,18 @@ import java.net.SocketAddress; public class WebModule extends LifecycleModule { private final AuthConfig authConfig; private final boolean wantSSL; - private final GitWebCgiConfig gitWebCgiConfig; + private final GitwebCgiConfig gitwebCgiConfig; private final GerritOptions options; @Inject WebModule(AuthConfig authConfig, @CanonicalWebUrl @Nullable String canonicalUrl, GerritOptions options, - GitWebCgiConfig gitWebCgiConfig) { + GitwebCgiConfig gitwebCgiConfig) { this.authConfig = authConfig; this.wantSSL = canonicalUrl != null && canonicalUrl.startsWith("https:"); this.options = options; - this.gitWebCgiConfig = gitWebCgiConfig; + this.gitwebCgiConfig = gitwebCgiConfig; } @Override @@ -75,8 +75,8 @@ public class WebModule extends LifecycleModule { install(new GerritRequestModule()); install(new GitOverHttpServlet.Module(options.enableMasterFeatures())); - if (gitWebCgiConfig.getGitwebCgi() != null) { - install(new GitWebModule()); + if (gitwebCgiConfig.getGitwebCgi() != null) { + install(new GitwebModule()); } DynamicSet.setOf(binder(), WebUiPlugin.class); diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitLogoServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitLogoServlet.java index 62dfc24a47..48c46a5d1f 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitLogoServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitLogoServlet.java @@ -17,7 +17,7 @@ package com.google.gerrit.httpd.gitweb; import static com.google.gerrit.common.FileUtil.lastModified; import com.google.common.io.ByteStreams; -import com.google.gerrit.server.config.GitWebCgiConfig; +import com.google.gerrit.server.config.GitwebCgiConfig; import com.google.gwtexpui.server.CacheHeaders; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -41,7 +41,7 @@ class GitLogoServlet extends HttpServlet { private final byte[] raw; @Inject - GitLogoServlet(GitWebCgiConfig cfg) throws IOException { + GitLogoServlet(GitwebCgiConfig cfg) throws IOException { byte[] png; Path src = cfg.getGitLogoPng(); if (src != null) { diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebCssServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebCssServlet.java similarity index 91% rename from gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebCssServlet.java rename to gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebCssServlet.java index 5ea2253baa..c9b57ac360 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebCssServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebCssServlet.java @@ -17,7 +17,7 @@ package com.google.gerrit.httpd.gitweb; import static com.google.gerrit.common.FileUtil.lastModified; import com.google.gerrit.httpd.HtmlDomUtil; -import com.google.gerrit.server.config.GitWebCgiConfig; +import com.google.gerrit.server.config.GitwebCgiConfig; import com.google.gerrit.server.config.SitePaths; import com.google.gwtexpui.server.CacheHeaders; import com.google.gwtjsonrpc.server.RPCServletUtils; @@ -34,9 +34,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @SuppressWarnings("serial") -abstract class GitWebCssServlet extends HttpServlet { +abstract class GitwebCssServlet extends HttpServlet { @Singleton - static class Site extends GitWebCssServlet { + static class Site extends GitwebCssServlet { @Inject Site(SitePaths paths) throws IOException { super(paths.site_css); @@ -44,9 +44,9 @@ abstract class GitWebCssServlet extends HttpServlet { } @Singleton - static class Default extends GitWebCssServlet { + static class Default extends GitwebCssServlet { @Inject - Default(GitWebCgiConfig gwcc) throws IOException { + Default(GitwebCgiConfig gwcc) throws IOException { super(gwcc.getGitwebCss()); } } @@ -57,7 +57,7 @@ abstract class GitWebCssServlet extends HttpServlet { private final byte[] raw_css; private final byte[] gz_css; - GitWebCssServlet(final Path src) + GitwebCssServlet(final Path src) throws IOException { if (src != null) { final Path dir = src.getParent(); diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebJavaScriptServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebJavaScriptServlet.java similarity index 91% rename from gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebJavaScriptServlet.java rename to gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebJavaScriptServlet.java index 617167b751..cfbd24bb88 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebJavaScriptServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebJavaScriptServlet.java @@ -17,7 +17,7 @@ package com.google.gerrit.httpd.gitweb; import static com.google.gerrit.common.FileUtil.lastModified; import com.google.common.io.ByteStreams; -import com.google.gerrit.server.config.GitWebCgiConfig; +import com.google.gerrit.server.config.GitwebCgiConfig; import com.google.gwtexpui.server.CacheHeaders; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -36,14 +36,14 @@ import javax.servlet.http.HttpServletResponse; @SuppressWarnings("serial") @Singleton -class GitWebJavaScriptServlet extends HttpServlet { +class GitwebJavaScriptServlet extends HttpServlet { private final long modified; private final byte[] raw; @Inject - GitWebJavaScriptServlet(GitWebCgiConfig gitWebCgiConfig) throws IOException { + GitwebJavaScriptServlet(GitwebCgiConfig gitwebCgiConfig) throws IOException { byte[] png; - Path src = gitWebCgiConfig.getGitwebJs(); + Path src = gitwebCgiConfig.getGitwebJs(); if (src != null) { try (InputStream in = Files.newInputStream(src)) { png = ByteStreams.toByteArray(in); diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebModule.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebModule.java similarity index 74% rename from gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebModule.java rename to gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebModule.java index 14ccf8921a..e73cb1154e 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebModule.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebModule.java @@ -16,13 +16,13 @@ package com.google.gerrit.httpd.gitweb; import com.google.inject.servlet.ServletModule; -public class GitWebModule extends ServletModule { +public class GitwebModule extends ServletModule { @Override protected void configureServlets() { - serve("/gitweb").with(GitWebServlet.class); + serve("/gitweb").with(GitwebServlet.class); serve("/gitweb-logo.png").with(GitLogoServlet.class); - serve("/gitweb.js").with(GitWebJavaScriptServlet.class); - serve("/gitweb-default.css").with(GitWebCssServlet.Default.class); - serve("/gitweb-site.css").with(GitWebCssServlet.Site.class); + serve("/gitweb.js").with(GitwebJavaScriptServlet.class); + serve("/gitweb-default.css").with(GitwebCssServlet.Default.class); + serve("/gitweb-site.css").with(GitwebCssServlet.Site.class); } } diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebServlet.java similarity index 97% rename from gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebServlet.java rename to gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebServlet.java index 57126a5642..c39962a267 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebServlet.java @@ -38,8 +38,8 @@ import com.google.gerrit.server.AnonymousUser; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.config.GerritServerConfig; -import com.google.gerrit.server.config.GitWebCgiConfig; -import com.google.gerrit.server.config.GitWebConfig; +import com.google.gerrit.server.config.GitwebCgiConfig; +import com.google.gerrit.server.config.GitwebConfig; import com.google.gerrit.server.config.SitePaths; import com.google.gerrit.server.git.LocalDiskRepositoryManager; import com.google.gerrit.server.project.NoSuchProjectException; @@ -82,9 +82,9 @@ import javax.servlet.http.HttpServletResponse; /** Invokes {@code gitweb.cgi} for the project given in {@code p}. */ @SuppressWarnings("serial") @Singleton -class GitWebServlet extends HttpServlet { +class GitwebServlet extends HttpServlet { private static final Logger log = - LoggerFactory.getLogger(GitWebServlet.class); + LoggerFactory.getLogger(GitwebServlet.class); private static final String PROJECT_LIST_ACTION = "project_list"; @@ -99,24 +99,24 @@ class GitWebServlet extends HttpServlet { private final EnvList _env; @Inject - GitWebServlet(LocalDiskRepositoryManager repoManager, + GitwebServlet(LocalDiskRepositoryManager repoManager, ProjectControl.Factory projectControl, Provider anonymousUserProvider, Provider userProvider, SitePaths site, @GerritServerConfig Config cfg, SshInfo sshInfo, - GitWebConfig gitWebConfig, - GitWebCgiConfig gitWebCgiConfig) + GitwebConfig gitwebConfig, + GitwebCgiConfig gitwebCgiConfig) throws IOException { this.repoManager = repoManager; this.projectControl = projectControl; this.anonymousUserProvider = anonymousUserProvider; this.userProvider = userProvider; - this.gitwebCgi = gitWebCgiConfig.getGitwebCgi(); + this.gitwebCgi = gitwebCgiConfig.getGitwebCgi(); this.deniedActions = new HashSet<>(); - final String url = gitWebConfig.getUrl(); + final String url = gitwebConfig.getUrl(); if ((url != null) && (!url.equals("gitweb"))) { URI uri = null; try { @@ -269,7 +269,7 @@ class GitWebServlet extends HttpServlet { } // Link back to Gerrit (when possible, to matching review record). - // Supported Gitweb's hash values are: + // Supported gitweb's hash values are: // - (missing), // - HEAD, // - refs/heads/, @@ -579,7 +579,7 @@ class GitWebServlet extends HttpServlet { env.set("REMOTE_USER", remoteUser); // Override CGI settings using alternative URI provided by gitweb.url. - // This is required to trick Gitweb into thinking that it's served under + // This is required to trick gitweb into thinking that it's served under // different URL. Setting just $my_uri on the perl's side isn't enough, // because few actions (atom, blobdiff_plain, commitdiff_plain) rely on // URL returned by $cgi->self_url(). @@ -644,7 +644,7 @@ class GitWebServlet extends HttpServlet { log.debug("Unexpected error copying input to CGI", e); } } - }, "GitWeb-InputFeeder").start(); + }, "Gitweb-InputFeeder").start(); } private void copyStderrToLog(final InputStream in) { @@ -666,7 +666,7 @@ class GitWebServlet extends HttpServlet { log.debug("Unexpected error copying stderr from CGI", e); } } - }, "GitWeb-ErrorLogger").start(); + }, "Gitweb-ErrorLogger").start(); } private static Enumeration enumerateHeaderNames(HttpServletRequest req) { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/config/GerritGlobalModule.java b/gerrit-server/src/main/java/com/google/gerrit/server/config/GerritGlobalModule.java index a6acb997d7..7d2b306998 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/config/GerritGlobalModule.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/config/GerritGlobalModule.java @@ -216,7 +216,7 @@ public class GerritGlobalModule extends FactoryModule { bind(ToolsCatalog.class); bind(EventFactory.class); bind(TransferConfig.class); - bind(GitWebConfig.class); + bind(GitwebConfig.class); bind(GcConfig.class); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/config/GetServerInfo.java b/gerrit-server/src/main/java/com/google/gerrit/server/config/GetServerInfo.java index 3a74f4abeb..cbcf6fcaaa 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/config/GetServerInfo.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/config/GetServerInfo.java @@ -18,7 +18,7 @@ import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.google.gerrit.common.data.GitWebType; +import com.google.gerrit.common.data.GitwebType; import com.google.gerrit.extensions.config.CloneCommand; import com.google.gerrit.extensions.config.DownloadCommand; import com.google.gerrit.extensions.config.DownloadScheme; @@ -51,7 +51,7 @@ public class GetServerInfo implements RestReadView { private final AllProjectsName allProjectsName; private final AllUsersName allUsersName; private final String anonymousCowardName; - private final GitWebConfig gitWebConfig; + private final GitwebConfig gitwebConfig; @Inject public GetServerInfo( @@ -65,7 +65,7 @@ public class GetServerInfo implements RestReadView { AllProjectsName allProjectsName, AllUsersName allUsersName, @AnonymousCowardName String anonymousCowardName, - GitWebConfig gitWebConfig) { + GitwebConfig gitwebConfig) { this.config = config; this.authConfig = authConfig; this.realm = realm; @@ -76,7 +76,7 @@ public class GetServerInfo implements RestReadView { this.allProjectsName = allProjectsName; this.allUsersName = allUsersName; this.anonymousCowardName = anonymousCowardName; - this.gitWebConfig = gitWebConfig; + this.gitwebConfig = gitwebConfig; } @Override @@ -89,7 +89,7 @@ public class GetServerInfo implements RestReadView { getDownloadInfo(downloadSchemes, downloadCommands, cloneCommands, archiveFormats); info.gerrit = getGerritInfo(config, allProjectsName, allUsersName); - info.gitWeb = getGitWebInfo(gitWebConfig); + info.gitweb = getGitwebInfo(gitwebConfig); info.sshd = getSshdInfo(config); info.suggest = getSuggestInfo(config); info.user = getUserInfo(anonymousCowardName); @@ -227,14 +227,14 @@ public class GetServerInfo implements RestReadView { return info; } - private GitWebInfo getGitWebInfo(GitWebConfig cfg) { - if (cfg.getUrl() == null || cfg.getGitWebType() == null) { + private GitwebInfo getGitwebInfo(GitwebConfig cfg) { + if (cfg.getUrl() == null || cfg.getGitwebType() == null) { return null; } - GitWebInfo info = new GitWebInfo(); + GitwebInfo info = new GitwebInfo(); info.url = cfg.getUrl(); - info.type = cfg.getGitWebType(); + info.type = cfg.getGitwebType(); return info; } @@ -274,7 +274,7 @@ public class GetServerInfo implements RestReadView { public ContactStoreInfo contactStore; public DownloadInfo download; public GerritInfo gerrit; - public GitWebInfo gitWeb; + public GitwebInfo gitweb; public SshdInfo sshd; public SuggestInfo suggest; public UserConfigInfo user; @@ -326,9 +326,9 @@ public class GetServerInfo implements RestReadView { public String reportBugText; } - public static class GitWebInfo { + public static class GitwebInfo { public String url; - public GitWebType type; + public GitwebType type; } public static class SshdInfo { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebCgiConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitwebCgiConfig.java similarity index 92% rename from gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebCgiConfig.java rename to gerrit-server/src/main/java/com/google/gerrit/server/config/GitwebCgiConfig.java index 63834f1cec..b7afa37c40 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebCgiConfig.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitwebCgiConfig.java @@ -28,12 +28,12 @@ import java.nio.file.Path; import java.nio.file.Paths; @Singleton -public class GitWebCgiConfig { +public class GitwebCgiConfig { private static final Logger log = - LoggerFactory.getLogger(GitWebCgiConfig.class); + LoggerFactory.getLogger(GitwebCgiConfig.class); - public GitWebCgiConfig disabled() { - return new GitWebCgiConfig(); + public GitwebCgiConfig disabled() { + return new GitwebCgiConfig(); } private final Path cgi; @@ -42,8 +42,8 @@ public class GitWebCgiConfig { private final Path logoPng; @Inject - GitWebCgiConfig(SitePaths sitePaths, @GerritServerConfig Config cfg) { - if (GitWebConfig.isDisabled(cfg)) { + GitwebCgiConfig(SitePaths sitePaths, @GerritServerConfig Config cfg) { + if (GitwebConfig.isDisabled(cfg)) { cgi = null; css = null; js = null; @@ -108,7 +108,7 @@ public class GitWebCgiConfig { this.logoPng = logo; } - private GitWebCgiConfig() { + private GitwebCgiConfig() { this.cgi = null; this.css = null; this.js = null; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitwebConfig.java similarity index 90% rename from gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java rename to gerrit-server/src/main/java/com/google/gerrit/server/config/GitwebConfig.java index c1fee2d852..10b9fb03bd 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/config/GitWebConfig.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/config/GitwebConfig.java @@ -19,15 +19,15 @@ import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.base.Strings.nullToEmpty; import com.google.common.base.Strings; -import com.google.gerrit.common.data.GitWebType; +import com.google.gerrit.common.data.GitwebType; import com.google.inject.Inject; import org.eclipse.jgit.lib.Config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class GitWebConfig { - private static final Logger log = LoggerFactory.getLogger(GitWebConfig.class); +public class GitwebConfig { + private static final Logger log = LoggerFactory.getLogger(GitwebConfig.class); public static boolean isDisabled(Config cfg) { return isEmptyString(cfg, "gitweb", null, "url") @@ -43,17 +43,17 @@ public class GitWebConfig { } /** - * Get a GitWebType based on the given config. + * Get a GitwebType based on the given config. * * @param cfg Gerrit config. - * @return GitWebType from the given name, else null if not found. + * @return GitwebType from the given name, else null if not found. */ - public static GitWebType typeFromConfig(Config cfg) { - GitWebType defaultType = defaultType(cfg.getString("gitweb", null, "type")); + public static GitwebType typeFromConfig(Config cfg) { + GitwebType defaultType = defaultType(cfg.getString("gitweb", null, "type")); if (defaultType == null) { return null; } - GitWebType type = new GitWebType(); + GitwebType type = new GitwebType(); type.setLinkName(firstNonNull( cfg.getString("gitweb", null, "linkname"), @@ -100,8 +100,8 @@ public class GitWebConfig { return type; } - private static GitWebType defaultType(String typeName) { - GitWebType type = new GitWebType(); + private static GitwebType defaultType(String typeName) { + GitwebType type = new GitwebType(); switch (nullToEmpty(typeName)) { case "": case "gitweb": @@ -140,10 +140,10 @@ public class GitWebConfig { } private final String url; - private final GitWebType type; + private final GitwebType type; @Inject - GitWebConfig(GitWebCgiConfig cgiConfig, @GerritServerConfig Config cfg) { + GitwebConfig(GitwebCgiConfig cgiConfig, @GerritServerConfig Config cfg) { if (isDisabled(cfg)) { type = null; url = null; @@ -151,7 +151,7 @@ public class GitWebConfig { } String cfgUrl = cfg.getString("gitweb", null, "url"); - GitWebType type = typeFromConfig(cfg); + GitwebType type = typeFromConfig(cfg); if (type == null) { this.type = null; url = null; @@ -186,8 +186,8 @@ public class GitWebConfig { } } - /** @return GitWebType for gitweb viewer. */ - public GitWebType getGitWebType() { + /** @return GitwebType for gitweb viewer. */ + public GitwebType getGitwebType() { return type; } diff --git a/gerrit-server/src/test/java/com/google/gerrit/server/config/GitWebConfigTest.java b/gerrit-server/src/test/java/com/google/gerrit/server/config/GitwebConfigTest.java similarity index 84% rename from gerrit-server/src/test/java/com/google/gerrit/server/config/GitWebConfigTest.java rename to gerrit-server/src/test/java/com/google/gerrit/server/config/GitwebConfigTest.java index 01b37e4da2..b03a381279 100644 --- a/gerrit-server/src/test/java/com/google/gerrit/server/config/GitWebConfigTest.java +++ b/gerrit-server/src/test/java/com/google/gerrit/server/config/GitwebConfigTest.java @@ -14,14 +14,12 @@ package com.google.gerrit.server.config; -import com.google.gerrit.server.config.GitWebConfig; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; -public class GitWebConfigTest { +public class GitwebConfigTest { private static final String VALID_CHARACTERS = "*()"; private static final String SOME_INVALID_CHARACTERS = "09AZaz$-_.+!',"; @@ -29,14 +27,14 @@ public class GitWebConfigTest { @Test public void testValidPathSeparator() { for(char c : VALID_CHARACTERS.toCharArray()) { - assertTrue("valid character rejected: " + c, GitWebConfig.isValidPathSeparator(c)); + assertTrue("valid character rejected: " + c, GitwebConfig.isValidPathSeparator(c)); } } @Test public void testInalidPathSeparator() { for(char c : SOME_INVALID_CHARACTERS.toCharArray()) { - assertFalse("invalid character accepted: " + c, GitWebConfig.isValidPathSeparator(c)); + assertFalse("invalid character accepted: " + c, GitwebConfig.isValidPathSeparator(c)); } } }