diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt index e07f9cbc56..ff635db1a2 100644 --- a/Documentation/config-gerrit.txt +++ b/Documentation/config-gerrit.txt @@ -1462,6 +1462,25 @@ at a specific branch when `custom` is used above. Valid replacements are `${project}` for the project name in Gerrit and `${branch}` for the name of the branch. +[[gitweb.roottree]]gitweb.roottree:: ++ +Optional pattern to use for constructing the gitweb URL when pointing +at the contents of the root tree in a specific commit when `custom` is +used above. ++ +Valid replacements are `${project}` for the project name in Gerrit +and `${commit}` for the SHA1 hash for the commit. + +[[gitweb.file]]gitweb.file:: ++ +Optional pattern to use for constructing the gitweb URL when pointing +at the contents of a file in a specific commit when `custom` is used +above. ++ +Valid replacements are `${project}` for the project name in Gerrit, +`${file}` for the file name and `${commit}` for the SHA1 hash for +the commit. + [[gitweb.filehistory]]gitweb.filehistory:: + Optional pattern to use for constructing the gitweb URL when pointing diff --git a/Documentation/config-gitweb.txt b/Documentation/config-gitweb.txt index 206fc0eb0c..5c912776f3 100644 --- a/Documentation/config-gitweb.txt +++ b/Documentation/config-gitweb.txt @@ -245,6 +245,8 @@ $ git config -f $site_path/etc/gerrit.config gitweb.type custom $ git config -f $site_path/etc/gerrit.config gitweb.project ?p=\${project}\;a=summary $ git config -f $site_path/etc/gerrit.config gitweb.revision ?p=\${project}\;a=commit\;h=\${commit} $ git config -f $site_path/etc/gerrit.config gitweb.branch ?p=\${project}\;a=shortlog\;h=\${branch} +$ git config -f $site_path/etc/gerrit.config gitweb.roottree ?p=\${project}\;a=tree\;hb=\${commit} +$ git config -f $site_path/etc/gerrit.config gitweb.file ?p=\${project}\;hb=\${commit}\;f=\${file} $ git config -f $site_path/etc/gerrit.config gitweb.filehistory ?p=\${project}\;a=history\;hb=\${branch}\;f=\${file} ---- @@ -252,8 +254,9 @@ After updating `'$site_path'/etc/gerrit.config`, the Gerrit server must be restarted and clients must reload the host page to see the change. Note that when using a custom gitweb configuration, values must be -specified for all of the `project`, `revision`, `branch` and `filehistory` -settings, otherwise the configuration will not be used. +specified for all of the `project`, `revision`, `branch`, `roottree`, +`file`, and `filehistory` settings, otherwise the configuration will +not be used. Access Control ++++++++++++++ diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitWebConfig.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitWebConfig.java index dfb1cc25a1..9d479770b0 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitWebConfig.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitWebConfig.java @@ -54,6 +54,8 @@ public class GitWebConfig { 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)); @@ -80,6 +82,12 @@ public class GitWebConfig { } else if (type.getRevision() == null) { log.warn("No Pattern specified for gitweb.revision, disabling."); type = null; + } else if (type.getRootTree() == null) { + log.warn("No Pattern specified for gitweb.roottree, disabling."); + type = null; + } else if (type.getFile() == null) { + log.warn("No Pattern specified for gitweb.file, disabling."); + type = null; } else if (type.getFileHistory() == null) { log.warn("No Pattern specified for gitweb.filehistory, disabling."); type = null;