Skip to content

Commit b1b8c4a

Browse files
achakilam-nvmfick-nvidia
authored andcommitted
Add ability to set base path in dev mode
Change-Id: I1da95745d1bc8eaa7d5b204a942bcee0b6a027a8
1 parent 06b65fd commit b1b8c4a

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

Documentation/config.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Default: `null`, determine the hostname from the local host.
3030
mode for that file. The link will only appear when you are browsing the file
3131
at a branch, so the commitish must start with `refs/heads/`.
3232

33+
`basePath` the base path for the gitiles urls. (only applicable for dev mode.)
34+
3335
> If you are using the Gerrit Gitiles plugin, this is set based on Gerrit's configuration.
3436
> Default: `null`, do not link `Change-Id` or show edit links.
3537
@@ -38,6 +40,7 @@ Default: `null`, determine the hostname from the local host.
3840
canonicalHostName = gitiles.example.org
3941
gerritUrl = https://gerrit.example.org/r/
4042
baseGitUrl = git://git.example.org/
43+
basePath = /additional/basepath/for/gitiles/
4144
```
4245

4346
### Repositories export

java/com/google/gitiles/dev/DevServer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import static com.google.common.base.MoreObjects.firstNonNull;
1818
import static com.google.gitiles.GitilesServlet.STATIC_PREFIX;
1919

20+
import com.google.common.base.MoreObjects;
2021
import com.google.common.base.Strings;
2122
import com.google.common.html.types.UncheckedConversions;
2223
import com.google.gitiles.BranchRedirect;
@@ -125,7 +126,7 @@ private Handler handler() throws IOException {
125126
return handlers;
126127
}
127128

128-
private Handler appHandler() {
129+
private Handler appHandler() throws UnknownHostException {
129130
DebugRenderer renderer =
130131
new DebugRenderer(
131132
STATIC_PREFIX,
@@ -144,7 +145,7 @@ private Handler appHandler() {
144145
}
145146

146147
ServletContextHandler handler = new ServletContextHandler();
147-
handler.setContextPath("");
148+
handler.setContextPath(MoreObjects.firstNonNull(cfg.getString("gitiles", null, "basePath"), ""));
148149
handler.addServlet(new ServletHolder(servlet), "/*");
149150
return handler;
150151
}

0 commit comments

Comments
 (0)