Merge changes I0f844eaa,Ife1777c0 * changes: Fix dev server configuration Format source code using google-java-format 1.24.0
diff --git a/Documentation/config.md b/Documentation/config.md index 869129a..29f328f 100644 --- a/Documentation/config.md +++ b/Documentation/config.md
@@ -16,6 +16,17 @@ siteTitle = Acme Inc. Git Browser ``` +### Base Path + +The file system path gitiles will scan for git repositories to serve when started +in dev mode using `./tools/dev_run.sh`. By default the current working directory +where the gitiles process was started from. + +``` +[gitiles] + basePath = /git/ +``` + ### URLs `canonicalHostName`. @@ -30,7 +41,7 @@ mode for that file. The link will only appear when you are browsing the file at a branch, so the commitish must start with `refs/heads/`. -`basePath` the base path for the gitiles urls. (only applicable for dev mode.) +`contextPath` the base path for the gitiles urls. Only applicable for dev mode started using `./tools/dev_run.sh`. > If you are using the Gerrit Gitiles plugin, this is set based on Gerrit's configuration. > Default: `null`, do not link `Change-Id` or show edit links. @@ -40,7 +51,7 @@ canonicalHostName = gitiles.example.org gerritUrl = https://gerrit.example.org/r/ baseGitUrl = git://git.example.org/ - basePath = /additional/basepath/for/gitiles/ + contextPath = /additional/basepath/for/gitiles/ ``` ### Repositories export
diff --git a/java/com/google/gitiles/dev/DevServer.java b/java/com/google/gitiles/dev/DevServer.java index f278239..042dd49 100644 --- a/java/com/google/gitiles/dev/DevServer.java +++ b/java/com/google/gitiles/dev/DevServer.java
@@ -145,7 +145,8 @@ } ServletContextHandler handler = new ServletContextHandler(); - handler.setContextPath(MoreObjects.firstNonNull(cfg.getString("gitiles", null, "basePath"), "")); + handler.setContextPath( + MoreObjects.firstNonNull(cfg.getString("gitiles", null, "contextPath"), "")); handler.addServlet(new ServletHolder(servlet), "/*"); return handler; }
diff --git a/javatests/com/google/gitiles/LinkifierTest.java b/javatests/com/google/gitiles/LinkifierTest.java index a51eccd..248cd40 100644 --- a/javatests/com/google/gitiles/LinkifierTest.java +++ b/javatests/com/google/gitiles/LinkifierTest.java
@@ -104,19 +104,28 @@ assertThat(l.linkify(REQ, "I0123456789")) .containsExactly( ImmutableMap.of( - "text", "I0123456789", "url", "http://test-host-review/path-prefix/#/q/I0123456789")) + "text", + "I0123456789", + "url", + "http://test-host-review/path-prefix/#/q/I0123456789")) .inOrder(); assertThat(l.linkify(REQ, "Change-Id: I0123456789")) .containsExactly( ImmutableMap.of("text", "Change-Id: "), ImmutableMap.of( - "text", "I0123456789", "url", "http://test-host-review/path-prefix/#/q/I0123456789")) + "text", + "I0123456789", + "url", + "http://test-host-review/path-prefix/#/q/I0123456789")) .inOrder(); assertThat(l.linkify(REQ, "Change-Id: I0123456789 exists")) .containsExactly( ImmutableMap.of("text", "Change-Id: "), ImmutableMap.of( - "text", "I0123456789", "url", "http://test-host-review/path-prefix/#/q/I0123456789"), + "text", + "I0123456789", + "url", + "http://test-host-review/path-prefix/#/q/I0123456789"), ImmutableMap.of("text", " exists")) .inOrder(); } @@ -149,7 +158,10 @@ "text", "http://my/url/I0123456789", "url", "http://my/url/I0123456789"), ImmutableMap.of("text", " is not change "), ImmutableMap.of( - "text", "I0123456789", "url", "http://test-host-review/path-prefix/#/q/I0123456789")) + "text", + "I0123456789", + "url", + "http://test-host-review/path-prefix/#/q/I0123456789")) .inOrder(); }
diff --git a/javatests/com/google/gitiles/LogServletTest.java b/javatests/com/google/gitiles/LogServletTest.java index 3357470..7d75849 100644 --- a/javatests/com/google/gitiles/LogServletTest.java +++ b/javatests/com/google/gitiles/LogServletTest.java
@@ -319,7 +319,7 @@ String path = "/repo/+log/refs/heads/master/bar"; FakeHttpServletResponse res = - buildResponse(path, "format=html" + "&n=" + 2 + "follow=1", SC_OK); + buildResponse(path, "format=html" + "&n=" + 2 + "follow=1", SC_OK); assertThat(res.getActualBodyString()).contains(c1.toObjectId().name()); assertThat(res.getActualBodyString()).contains(c2.toObjectId().name()); @@ -359,16 +359,16 @@ void enableAndWriteCommitGraph() throws Exception { repo.getRepository() - .getConfig() - .setBoolean( - ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_COMMIT_GRAPH, true); + .getConfig() + .setBoolean( + ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_COMMIT_GRAPH, true); repo.getRepository() - .getConfig() - .setBoolean( - ConfigConstants.CONFIG_COMMIT_GRAPH_SECTION, - null, - ConfigConstants.CONFIG_KEY_READ_CHANGED_PATHS, - true); + .getConfig() + .setBoolean( + ConfigConstants.CONFIG_COMMIT_GRAPH_SECTION, + null, + ConfigConstants.CONFIG_KEY_READ_CHANGED_PATHS, + true); DfsGarbageCollector gc = new DfsGarbageCollector(repo.getRepository()); gc.setWriteCommitGraph(true).setWriteBloomFilter(true).pack(NullProgressMonitor.INSTANCE); }