Allow gitweb URLs to be passed unencoded for viewing.

Gerrit composes the viewer URL using information
about the project, branch, file or commit of the
target object to be displayed.

Context:
Typically viewers such as CGit and GitWeb do need
those parts to be encoded, including the '/' in
project names, for being correctly parsed.
However other viewers could instead require
unencoded URL (e.g. GitHub web based viewer).

This patch allows to disable the URL encoding for
allowing GitHub to be used as "gitweb custom viewer"
on top of Gerrit.

Example of GitHub configured as viewer:

[gitweb]
    type = custom
    url = https://github.com/
    project = ${project}
    revision = ${project}/commit/${commit}
    branch = ${project}/tree/${branch}
    fileHistory = ${project}/blog/${branch}/${file}
    linkName = GitHub
    urlEncode = false

Change-Id: Ief59de7eb19def60c5e765c4a495bcac00384d83
This commit is contained in:
Luca Milanesio
2013-10-11 11:34:39 +01:00
parent 3670fce262
commit 2531203895
4 changed files with 31 additions and 2 deletions

View File

@@ -94,6 +94,10 @@ public class GitwebLink {
}
private String encode(String segment) {
return URL.encodeQueryString(type.replacePathSeparator(segment));
if (type.isUrlEncode()) {
return URL.encodeQueryString(type.replacePathSeparator(segment));
} else {
return segment;
}
}
}