Skip to content

Commit 2b89e88

Browse files
lucamilanesioGerrit Code Review
authored andcommitted
Merge "Add built-in documentation." into stable-2.11
2 parents 75e5975 + df29e6d commit 2b89e88

File tree

5 files changed

+120
-21
lines changed

5 files changed

+120
-21
lines changed

README.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,8 @@ repository aren't enough as they are missing some specific
1414
build parameters and constraints (i.e. shaded-jar) that are
1515
needed for a Gerrit plugin to work properly.
1616

17-
### Wicket
18-
You need to clone and build a modified version of Wicket that
19-
is currently published on GitHub under the GerritCodeReview
20-
organisation: https://github.com/GerritCodeReview/wicket.git
21-
22-
$ git clone https://github.com/GerritCodeReview/wicket.git
23-
$ git checkout wicket-1.4.23-gerrit
24-
$ mvn clean install -DskipTests
25-
2617
### Gitblit
18+
2719
You need to clone Gitblit from GitHub and build it locally
2820
using the installMaven ANT target.
2921

@@ -32,6 +24,7 @@ using the installMaven ANT target.
3224
$ ant -DresourceFolderPrefix=static installMaven
3325

3426
### Gitblit plugin
27+
3528
You are ready now to clone and build the Gitblit plugin: the
3629
Wicket and Giblit dependencies will be taken from your local
3730
Maven repository.
@@ -46,10 +39,11 @@ the following configuration to your Gerrit config.
4639
[gitweb]
4740
type = custom
4841
linkname = Gitblit
49-
url = plugins/
50-
revision = gitblit/commit/?r=${project}&h=${commit}
51-
project = gitblit/summary/?r=${project}
52-
branch = gitblit/log/?r=${project}&h=${branch}
53-
filehistory = gitblit/history/?f=${file}&r=${project}&h=${branch}
54-
file = gitblit/blob/?r=${project}&h=${commit}&f=${file}
55-
roottree = gitblit/tree/?r=${project}&h=${commit}
42+
url = plugins/gitblit/
43+
revision = commit/?r=${project}&h=${commit}
44+
project = summary/?r=${project}
45+
branch = log/?r=${project}&h=${branch}
46+
filehistory = history/?f=${file}&r=${project}&h=${branch}
47+
file = blob/?r=${project}&h=${commit}&f=${file}
48+
roottree = tree/?r=${project}&h=${commit}
49+

pom.xml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ limitations under the License.
3535
<Gerrit-Module>com.googlesource.gerrit.plugins.gitblit.GitBlitModule</Gerrit-Module>
3636
<Gerrit-HttpModule>com.googlesource.gerrit.plugins.gitblit.GitBlitServletModule</Gerrit-HttpModule>
3737
<wicket.version>1.4.23</wicket.version>
38+
<GitBlit-Version>1.7.0-SNAPSHOT</GitBlit-Version>
3839
</properties>
3940
<dependencies>
4041
<dependency>
@@ -46,7 +47,7 @@ limitations under the License.
4647
<dependency>
4748
<groupId>com.gitblit</groupId>
4849
<artifactId>gitblit</artifactId>
49-
<version>1.7.0-SNAPSHOT</version>
50+
<version>${GitBlit-Version}</version>
5051
</dependency>
5152
<dependency>
5253
<groupId>org.apache.wicket</groupId>
@@ -65,7 +66,31 @@ limitations under the License.
6566
</dependency>
6667
</dependencies>
6768
<build>
69+
<resources>
70+
<resource>
71+
<directory>src/main/resources</directory>
72+
<filtering>true</filtering>
73+
<includes>
74+
<include>**/*.md</include>
75+
</includes>
76+
</resource>
77+
<resource>
78+
<directory>src/main/resources</directory>
79+
<filtering>false</filtering>
80+
<excludes>
81+
<exclude>**/*.md</exclude>
82+
</excludes>
83+
</resource>
84+
</resources>
6885
<plugins>
86+
<plugin>
87+
<groupId>org.apache.maven.plugins</groupId>
88+
<artifactId>maven-resources-plugin</artifactId>
89+
<version>2.7</version>
90+
<configuration>
91+
<escapeString>\</escapeString>
92+
</configuration>
93+
</plugin>
6994
<plugin>
7095
<groupId>org.apache.maven.plugins</groupId>
7196
<artifactId>maven-compiler-plugin</artifactId>

src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitInitStep.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ private void initGitBlitPluginConfig() {
8080
"Repositories", true);
8181
pluginCfg
8282
.string("\"Activity\" submenu title", "activity", "Activity", true);
83+
pluginCfg.string("\"Documentation\" submenu title", "documentation",
84+
"Documentation", true);
8385
String originalValue = pluginCfg.get("search");
8486
if (originalValue == null) {
8587
pluginCfg

src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitTopMenu.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.List;
1919

2020
import com.google.common.collect.Lists;
21-
import com.google.gerrit.extensions.annotations.Listen;
2221
import com.google.gerrit.extensions.annotations.PluginCanonicalWebUrl;
2322
import com.google.gerrit.extensions.annotations.PluginName;
2423
import com.google.gerrit.extensions.client.GerritTopMenu;
@@ -29,7 +28,6 @@
2928
import com.google.inject.Inject;
3029
import com.google.inject.Provider;
3130

32-
@Listen
3331
public class GitBlitTopMenu implements TopMenu {
3432

3533
// Not configurable to avoid mis-configurations clashing with predefined top
@@ -59,8 +57,11 @@ public GitBlitTopMenu(@PluginName String pluginName,
5957
MenuItem repositories =
6058
new MenuItem(cfg.getString("repositories", "Repositories"),
6159
gitBlitBaseUrl + "repositories/", "");
62-
restrictedMenuEntries =
63-
new MenuEntry(GITBLIT_TOPMENU_NAME, Arrays.asList(repositories));
60+
// GitBlit handles its own "/" url, so Gerrit won't produce any link, not even on the "plugins" page, that would display the documentation.
61+
// I've considered simply redirecting "/" to "/Documentation/" since GitBlit's "/" screen is very similar to its "/activity/" screen, but
62+
// decided finally to provide an explicit documentation submenu instead.
63+
MenuItem documentation = new MenuItem(cfg.getString("documentation", "Documentation"), gitBlitBaseUrl + "Documentation/", "");
64+
restrictedMenuEntries = new MenuEntry(GITBLIT_TOPMENU_NAME, Arrays.asList(repositories, documentation));
6465
List<MenuItem> fullMenuItems = Lists.newArrayList();
6566
fullMenuItems.add(repositories);
6667
fullMenuItems.add(new MenuItem(cfg.getString("activity", "Activity"),
@@ -69,6 +70,7 @@ public GitBlitTopMenu(@PluginName String pluginName,
6970
if (search != null && !search.isEmpty()) {
7071
fullMenuItems.add(new MenuItem(search, gitBlitBaseUrl + "lucene/", ""));
7172
}
73+
fullMenuItems.add(documentation);
7274
fullMenuEntries = new MenuEntry(GITBLIT_TOPMENU_NAME, fullMenuItems);
7375
extraProjectEntries =
7476
new MenuEntry(GerritTopMenu.PROJECTS, Arrays.asList(new MenuItem(cfg
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# GitBlit plugin
2+
3+
This plugin integrates [GitBlit](https://github.com/gitblit/gitblit) _${GitBlit-Version}_ as a repository browser into [Gerrit](https://code.google.com/p/gerrit/),
4+
with full SSO through Gerrit.
5+
6+
* License: [Apache Public License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
7+
* [Home page](https://gerrit.googlesource.com/plugins/gitblit/+/refs/heads/master/README.md)
8+
* Installed plugin version: _${pom.version}_
9+
10+
# Configuration
11+
12+
There are two different configurations: one for Gerrit so it knows how to generate links that will be processed by the plugin, and
13+
an optional GitBlit configuration for the plugin itself.
14+
15+
## Gerrit configuration
16+
17+
In Gerrit's `gerrit.config`, define the `[gitweb]` section as follows:
18+
19+
[gitweb]
20+
type = custom
21+
url = plugins/@PLUGIN@/
22+
linkname = browse
23+
project = summary/?r=${project}
24+
revision = commit/?r=${project}&h=${commit}
25+
branch = log/?r=${project}&h=${branch}
26+
filehistory = history/?f=\${file}&r=${project}&h=${branch}
27+
file = blob/?r=${project}&h=${commit}&f=\${file}
28+
roottree = tree/?r=${project}&h=${commit}
29+
30+
This is normally done automatically if you add the plugin and run through `java -jar gerrit.war init -d site_path`, but you can also
31+
add this manually to Gerrit's config file. The `linkname` can be adapted to your taste.
32+
33+
### Configuring the top menu
34+
35+
This plugin adds a "GitBlit" top menu to Gerrit, and also a new sub-menu item to the "Projects" top menu. Since v2.11 of this plugin, the link
36+
texts for all sub-menu items can be configured to your taste in a `[plugin "@PLUGIN@"]` section in your `gerrit.config`. If the section is not present,
37+
or some values in that section are not defined, the plugin uses built-in default texts. The default configuration would correspond to
38+
39+
[plugin "@PLUGIN@"]
40+
repositories = Repositories
41+
activity = Activity
42+
documentation = Documentation
43+
search =
44+
browse = Browse
45+
46+
The first four are sub-menu items of the "GitBlit" top menu, the last one is a new "browse" sub-menu item in Gerrit's "Projects" menu that is shown
47+
for Gerrit's "current" project (since v2.11).
48+
49+
The "search" sub-menu item is by default not set and will thus not be shown. Setting it makes only sense if you enable GitBlit indexing on some of
50+
your projects.
51+
52+
## GitBlit configuration
53+
54+
The plugin includes in the JAR a minimal default configuration to make GitBlit act only as a repository viewer. You can provide your own
55+
customized [`gitblit.properties`](http://gitblit.com/properties.html) file located in Gerrit's `$GERRIT_SITE/etc` directory.
56+
The `$GERRIT_SITE/etc/gitblit.properties` takes precedence over the pre-defined configuration settings.
57+
58+
P.S. The following two GitBlit properties are not configurable as changing them would break the plugin functionality:
59+
60+
- git.repositoriesFolder is hardcoded to point to Gerrit repositories directory
61+
- realm.userService is hardcoded to resolve GitBlit users using Gerrit authentication realm
62+
63+
Additionally the GitBlit ticket service is not available as would not make sense when used in a read only
64+
repository viewer.
65+
66+
The built-in configuration is archived in the GitBlit source repository. The latest version on master is
67+
[`gitblit.properties`](https://gerrit.googlesource.com/plugins/gitblit/+/master/src/main/resources/gitblit.properties).
68+
69+
# Issue tracking
70+
71+
Report bugs or make feature requests at the [Gerrit issue tracker](https://code.google.com/p/gerrit/issues/list).
72+
73+
<hr style="color: #C0C0C0; background-color: #C0C0C0; border-color: #C0C0C0; height: 2px;" />
74+
<div style="float:right;">
75+
<a href="https://gerrit-review.googlesource.com/#/admin/projects/plugins/gitblit,dashboards" target="_blank">GitBlit plugin ${pom.version}</a>
76+
</div>

0 commit comments

Comments
 (0)