blob: fb7c961f5673316dfce58c7739b3e7fae9b535a5 [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001== Gitweb Integration
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08002
Shawn O. Pearce618dae22010-03-12 19:07:43 -08003Gerrit Code Review can manage and generate hyperlinks to gitweb,
4allowing users to jump from Gerrit content to the same information,
5but shown by gitweb.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08006
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08007=== Internal/Managed gitweb
Shawn O. Pearce618dae22010-03-12 19:07:43 -08008
9In the internal configuration, Gerrit inspects the request, enforces
10its project level access controls, and directly executes `gitweb.cgi`
11if the user is authorized to view the page.
12
13To enable the internal configuration, set
14link:config-gerrit.html#gitweb.cgi[gitweb.cgi] with the path of the
15installed CGI. This defaults to `/usr/lib/cgi-bin/gitweb.cgi`,
16which is a common installation path for the 'gitweb' package on
17Linux distributions.
18
19====
20 git config --file $site_path/etc/gerrit.config gitweb.cgi /usr/lib/cgi-bin/gitweb.cgi
Piotr Sikora6a9d47e2011-02-27 21:22:32 +000021 git config --file $site_path/etc/gerrit.config --unset gitweb.url
22====
23
24Alternatively, if Gerrit is served behind reverse proxy, it can
25generate different URLs for gitweb's links (they need to be
26rewritten to `<gerrit>/gitweb?args` on the web server). This allows
David Pursehouse221d4f62012-06-08 17:38:08 +090027for serving gitweb under a different URL than the Gerrit instance.
Piotr Sikora6a9d47e2011-02-27 21:22:32 +000028To enable this feature, set both: `gitweb.cgi` and `gitweb.url`.
29
30====
31 git config --file $site_path/etc/gerrit.config gitweb.cgi /usr/lib/cgi-bin/gitweb.cgi
32 git config --file $site_path/etc/gerrit.config gitweb.url /pretty/path/to/gitweb
Shawn O. Pearce618dae22010-03-12 19:07:43 -080033====
34
35After updating `'$site_path'/etc/gerrit.config`, the Gerrit server must
36be restarted and clients must reload the host page to see the change.
37
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080038==== Configuration
Shawn O. Pearce544220c2010-03-13 17:39:35 -080039
40Most of the gitweb configuration file is handled automatically
41by Gerrit Code Review. Site specific overrides can be placed in
42`'$site_path'/etc/gitweb_config.perl`, as this file is loaded as
43part of the generated configuration file.
44
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080045==== Logo and CSS
Shawn O. Pearcea57697b2010-03-13 18:23:47 -080046
47If the package-manager installed CGI (`/usr/lib/cgi-bin/gitweb.cgi`)
48is being used, the stock CSS and logo files will be served from
49either `/usr/share/gitweb` or `/var/www`.
50
51Otherwise, Gerrit expects `gitweb.css` and `git-logo.png` to be found
52in the same directory as the CGI script itself. This matches with
53the default source code distribution, and most custom installations.
54
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080055==== Access Control
Shawn O. Pearce618dae22010-03-12 19:07:43 -080056
57Access controls for internally managed gitweb page views are enforced
58using the standard project READ +1 permission.
59
Warren Turkalf8101aa2013-12-11 15:56:53 -080060Also, in order for a user to be able to view any gitweb information for a
David Pursehouse659860f2013-12-16 14:50:04 +090061project, the user must be able to read all references (including
Warren Turkalf8101aa2013-12-11 15:56:53 -080062refs/meta/config, refs/meta/dashboards/*, etc.). If you have exclusive read
63permissions for any references, make sure to include all parties that should be
64able to read the gitweb info for any of the branches in that project.
65
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080066=== External/Unmanaged gitweb
Shawn O. Pearce618dae22010-03-12 19:07:43 -080067
jhuntleyd7f53712012-08-01 14:19:46 -040068For the external configuration, gitweb runs under the control of an
69external web server, and Gerrit access controls are not enforced. Gerrit
70provides configuration parameters for integration with GitWeb.
71
72[[linuxGitWeb]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080073==== Linux Installation
jhuntleyd7f53712012-08-01 14:19:46 -040074
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080075===== Install GitWeb
jhuntleyd7f53712012-08-01 14:19:46 -040076
77On Ubuntu:
78
79====
80 sudo apt-get install gitweb
81====
82
83With Yum:
84
85====
86 $ yum install gitweb
87====
88
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080089===== Configure GitWeb
jhuntleyd7f53712012-08-01 14:19:46 -040090
91
92Update `/etc/gitweb.conf`, add the public GIT repositories:
93
94----
95$projectroot = "/var/www/repo/";
96
97# directory to use for temp files
98$git_temp = "/tmp";
99
100# target of the home link on top of all pages
101#$home_link = $my_uri || "/";
102
103# html text to include at home page
104$home_text = "indextext.html";
105
106# file with project list; by default, simply scan the projectroot dir.
107$projects_list = $projectroot;
108
109# stylesheet to use
110# I took off the prefix / of the following path to put these files inside gitweb directory directly
111$stylesheet = "gitweb.css";
112
113# logo to use
114$logo = "git-logo.png";
115
Christian Aistleitner21b3b3a2013-05-09 22:32:45 +0200116# the favicon
jhuntleyd7f53712012-08-01 14:19:46 -0400117$favicon = "git-favicon.png";
118----
119
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800120==== Configure & Restart Apache Web Server
jhuntleyd7f53712012-08-01 14:19:46 -0400121
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800122===== Configure Apache
jhuntleyd7f53712012-08-01 14:19:46 -0400123
124
125Link gitweb to `/var/www/gitweb`, check `/etc/gitweb.conf` if unsure of paths:
126
127====
128 $ sudo ln -s /usr/share/gitweb /var/www/gitweb
129====
130
131Add the gitweb directory to the Apache configuration by creating a "gitweb"
132file inside the Apache conf.d directory:
133
134====
135 $ touch /etc/apache/conf.d/gitweb
136====
137
138Add the following to /etc/apache/conf.d/gitweb:
139
140----
141Alias /gitweb /var/www/gitweb
142
143Options Indexes FollowSymlinks ExecCGI
144DirectoryIndex /cgi-bin/gitweb.cgi
145AllowOverride None
146----
147
148*NOTE* This may have already been added by yum/apt-get. If that's the case, leave as
149is.
150
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800151===== Restart the Apache Web Server
jhuntleyd7f53712012-08-01 14:19:46 -0400152
153====
154$ sudo /etc/init.d/apache2 restart
155====
156
157Now you should be able to view your repository projects online:
158
159link:http://localhost/gitweb[http://localhost/gitweb]
160
161[[WindowsGitWeb]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800162==== Windows Installation
jhuntleyd7f53712012-08-01 14:19:46 -0400163
164Instructions are available for installing the GitWeb module distributed with
165MsysGit:
166
167link:https://github.com/msysgit/msysgit/wiki/GitWeb[GitWeb]
168
169If you don't have Apache installed, you can download the appropriate build for
170Windows from link:http://www.apachelounge.com/download[apachelounge.org].
171
172After you have installed Apache, you will want to create a link:http://httpd.apache.org/docs/2.0/platform/windows.html#winsvc[new service user
173account] to use with Apache.
174
175If you're still having difficulty setting up permissions, you may find this
176tech note useful for configuring Apache Service to run under another account.
177You must grant the new account link:http://technet.microsoft.com/en-us/library/cc794944(WS.10).aspx["run as service"] permission:
178
179The GitWeb version in msysgit is missing several important and required
180perl modules, including CGI.pm. The perl included with the msysgit distro 1.7.8
181is broken.. The link:http://groups.google.com/group/msysgit/browse_thread/thread/ba3501f1f0ed95af[unicore folder is missing along with utf8_heavy.pl and CGI.pm]. You can
182verify by checking for perl modules. From an msys console, execute the
183following to check:
184
185====
186$ perl -mCGI -mEncode -mFcntl -mFile::Find -mFile::Basename -e ""
187====
188
189You may encounter the following exception:
190
191----
192$ perl -mCGI -mEncode -mFcntl -mFile::Find -mFile::Basename -e ""
193Can't locate CGI.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8/msys
194/usr/lib/p erl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/msys
195/usr/lib/perl5/site_perl/5.8.8 /u sr/lib/perl5/site_perl .). BEGIN
196failed--compilation aborted.
197----
198
199If you're missing CGI.pm, you'll have to deploy the module to the msys
200environment: You will have to retrieve them from the 5.8.8 distro on :
201
202http://strawberryperl.com/releases.html
203
204File: strawberry-perl-5.8.8.3.zip
205
206contents: `bin/` `lib/` `site/`
207
208copy the contents of lib into `msysgit/lib/perl5/5.8.8` and overwrite existing files.
209
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800210==== Enable GitWeb Integration
Shawn O. Pearce618dae22010-03-12 19:07:43 -0800211
212To enable the external gitweb integration, set
213link:config-gerrit.html#gitweb.url[gitweb.url] with the URL of your
214gitweb CGI.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800215
Shawn O. Pearce9743d0b2009-06-01 10:10:06 -0700216The CGI's `$projectroot` should be the same directory as
217gerrit.basePath, or a fairly current replica. If a replica is
218being used, ensure it uses a full mirror, so the `refs/changes/*`
219namespace is available.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800220
jhuntleyd7f53712012-08-01 14:19:46 -0400221----
222$ git config -f $site_path/etc/gerrit.config gitweb.cgi $PATH_TO_GITWEB/gitweb.cgi
223$ git config -f $site_path/etc/gerrit.config gitweb.url https://gitweb.corporation.com
224----
225
226If you're not following the traditional \{projectName\}.git project naming conventions,
227you will want to customize Gerrit to read them. Add the following:
228
229----
230$ git config -f $site_path/etc/gerrit.config gitweb.type custom
231$ git config -f $site_path/etc/gerrit.config gitweb.project ?p=\${project}\;a=summary
232$ git config -f $site_path/etc/gerrit.config gitweb.revision ?p=\${project}\;a=commit\;h=\${commit}
233$ git config -f $site_path/etc/gerrit.config gitweb.branch ?p=\${project}\;a=shortlog\;h=\${branch}
Colby Ranger79d4ebe2013-12-16 14:19:18 -0800234$ git config -f $site_path/etc/gerrit.config gitweb.roottree ?p=\${project}\;a=tree\;hb=\${commit}
235$ git config -f $site_path/etc/gerrit.config gitweb.file ?p=\${project}\;hb=\${commit}\;f=\${file}
jhuntleyd7f53712012-08-01 14:19:46 -0400236$ git config -f $site_path/etc/gerrit.config gitweb.filehistory ?p=\${project}\;a=history\;hb=\${branch}\;f=\${file}
237----
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800238
Shawn O. Pearcec5fed822009-11-17 16:10:10 -0800239After updating `'$site_path'/etc/gerrit.config`, the Gerrit server must
Shawn O. Pearced7ba11f2009-06-01 09:35:41 -0700240be restarted and clients must reload the host page to see the change.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800241
David Pursehouse8264ef72013-10-18 17:50:54 +0900242Note that when using a custom gitweb configuration, values must be
Colby Ranger79d4ebe2013-12-16 14:19:18 -0800243specified for all of the `project`, `revision`, `branch`, `roottree`,
244`file`, and `filehistory` settings, otherwise the configuration will
245not be used.
David Pursehouse8264ef72013-10-18 17:50:54 +0900246
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800247===== Access Control
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800248
249Gitweb access controls can be implemented using standard web server
250access controls. This isn't typically integrated with Gerrit's own
251access controls. Caution must be taken to ensure the controls are
252consistent if access needs to be restricted.
253
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800254===== Caching Gitweb
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800255
256If your repository set is large and you are expecting a lot
257of users, you may want to look at the caching forks used by
258high-traffic sites like kernel.org or repo.or.cz.
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700259
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800260=== Alternatives to gitweb
Shane Mc Cormack27868a42009-12-28 04:49:39 +0000261There are other alternatives to gitweb that can also be used with
262Gerrit, such as cgit.
263
264cgit can be used by specifying `gitweb.type` to be 'cgit'.
265
266It is also possible to define custom patterns.
267
Fredrik Luthandera6bb9512014-03-24 18:59:45 -0700268=== SEE ALSO
Shawn O. Pearced7ba11f2009-06-01 09:35:41 -0700269
Shawn O. Pearce8efb2a72009-08-18 19:45:33 -0700270* link:config-gerrit.html#gitweb[Section gitweb]
Shane Mc Cormack27868a42009-12-28 04:49:39 +0000271* link:http://hjemli.net/git/cgit/[cgit]
Shawn O. Pearced7ba11f2009-06-01 09:35:41 -0700272
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700273GERRIT
274------
275Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700276
277SEARCHBOX
278---------