blob: 46c9ced2b409af62d4f0cecbe5fa3ab4eaee557a [file] [log] [blame]
Marian Harbachebeb1542019-12-13 10:42:46 +01001:linkattrs:
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08002== Gitweb Integration
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08003
Shawn O. Pearce618dae22010-03-12 19:07:43 -08004Gerrit Code Review can manage and generate hyperlinks to gitweb,
5allowing users to jump from Gerrit content to the same information,
6but shown by gitweb.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08007
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08008=== Internal/Managed gitweb
Shawn O. Pearce618dae22010-03-12 19:07:43 -08009
10In the internal configuration, Gerrit inspects the request, enforces
11its project level access controls, and directly executes `gitweb.cgi`
12if the user is authorized to view the page.
13
14To enable the internal configuration, set
15link:config-gerrit.html#gitweb.cgi[gitweb.cgi] with the path of the
16installed CGI. This defaults to `/usr/lib/cgi-bin/gitweb.cgi`,
17which is a common installation path for the 'gitweb' package on
18Linux distributions.
19
Michael Ochmannb99feab2016-07-06 14:10:22 +020020----
David Pursehousef7c63f62018-03-16 09:47:32 +090021 git config -f $site_path/etc/gerrit.config gitweb.type gitweb
David Pursehouse312e9732018-03-16 09:45:24 +090022 git config -f $site_path/etc/gerrit.config gitweb.cgi /usr/lib/cgi-bin/gitweb.cgi
23 git config -f $site_path/etc/gerrit.config --unset gitweb.url
Michael Ochmannb99feab2016-07-06 14:10:22 +020024----
Piotr Sikora6a9d47e2011-02-27 21:22:32 +000025
26Alternatively, if Gerrit is served behind reverse proxy, it can
27generate different URLs for gitweb's links (they need to be
28rewritten to `<gerrit>/gitweb?args` on the web server). This allows
David Pursehouse221d4f62012-06-08 17:38:08 +090029for serving gitweb under a different URL than the Gerrit instance.
Piotr Sikora6a9d47e2011-02-27 21:22:32 +000030To enable this feature, set both: `gitweb.cgi` and `gitweb.url`.
31
Michael Ochmannb99feab2016-07-06 14:10:22 +020032----
David Pursehousef7c63f62018-03-16 09:47:32 +090033 git config -f $site_path/etc/gerrit.config gitweb.type gitweb
David Pursehouse312e9732018-03-16 09:45:24 +090034 git config -f $site_path/etc/gerrit.config gitweb.cgi /usr/lib/cgi-bin/gitweb.cgi
35 git config -f $site_path/etc/gerrit.config gitweb.url /pretty/path/to/gitweb
Michael Ochmannb99feab2016-07-06 14:10:22 +020036----
Shawn O. Pearce618dae22010-03-12 19:07:43 -080037
38After updating `'$site_path'/etc/gerrit.config`, the Gerrit server must
39be restarted and clients must reload the host page to see the change.
40
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080041==== Configuration
Shawn O. Pearce544220c2010-03-13 17:39:35 -080042
43Most of the gitweb configuration file is handled automatically
44by Gerrit Code Review. Site specific overrides can be placed in
45`'$site_path'/etc/gitweb_config.perl`, as this file is loaded as
46part of the generated configuration file.
47
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080048==== Logo and CSS
Shawn O. Pearcea57697b2010-03-13 18:23:47 -080049
50If the package-manager installed CGI (`/usr/lib/cgi-bin/gitweb.cgi`)
51is being used, the stock CSS and logo files will be served from
52either `/usr/share/gitweb` or `/var/www`.
53
54Otherwise, Gerrit expects `gitweb.css` and `git-logo.png` to be found
55in the same directory as the CGI script itself. This matches with
56the default source code distribution, and most custom installations.
57
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080058==== Access Control
Shawn O. Pearce618dae22010-03-12 19:07:43 -080059
60Access controls for internally managed gitweb page views are enforced
61using the standard project READ +1 permission.
62
Warren Turkalf8101aa2013-12-11 15:56:53 -080063Also, in order for a user to be able to view any gitweb information for a
David Pursehouse659860f2013-12-16 14:50:04 +090064project, the user must be able to read all references (including
Warren Turkalf8101aa2013-12-11 15:56:53 -080065refs/meta/config, refs/meta/dashboards/*, etc.). If you have exclusive read
66permissions for any references, make sure to include all parties that should be
67able to read the gitweb info for any of the branches in that project.
68
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080069=== External/Unmanaged gitweb
Shawn O. Pearce618dae22010-03-12 19:07:43 -080070
jhuntleyd7f53712012-08-01 14:19:46 -040071For the external configuration, gitweb runs under the control of an
72external web server, and Gerrit access controls are not enforced. Gerrit
Dave Borowitza3d67882015-06-05 15:22:23 -070073provides configuration parameters for integration with gitweb.
jhuntleyd7f53712012-08-01 14:19:46 -040074
75[[linuxGitWeb]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080076==== Linux Installation
jhuntleyd7f53712012-08-01 14:19:46 -040077
Dave Borowitza3d67882015-06-05 15:22:23 -070078===== Install Gitweb
jhuntleyd7f53712012-08-01 14:19:46 -040079
80On Ubuntu:
81
Michael Ochmannb99feab2016-07-06 14:10:22 +020082----
David Pursehouse312e9732018-03-16 09:45:24 +090083 sudo apt-get install gitweb
Michael Ochmannb99feab2016-07-06 14:10:22 +020084----
jhuntleyd7f53712012-08-01 14:19:46 -040085
86With Yum:
87
Michael Ochmannb99feab2016-07-06 14:10:22 +020088----
David Pursehouse312e9732018-03-16 09:45:24 +090089 yum install gitweb
Michael Ochmannb99feab2016-07-06 14:10:22 +020090----
jhuntleyd7f53712012-08-01 14:19:46 -040091
Dave Borowitza3d67882015-06-05 15:22:23 -070092===== Configure Gitweb
jhuntleyd7f53712012-08-01 14:19:46 -040093
94
95Update `/etc/gitweb.conf`, add the public GIT repositories:
96
97----
98$projectroot = "/var/www/repo/";
99
100# directory to use for temp files
101$git_temp = "/tmp";
102
103# target of the home link on top of all pages
104#$home_link = $my_uri || "/";
105
106# html text to include at home page
107$home_text = "indextext.html";
108
109# file with project list; by default, simply scan the projectroot dir.
110$projects_list = $projectroot;
111
112# stylesheet to use
113# I took off the prefix / of the following path to put these files inside gitweb directory directly
114$stylesheet = "gitweb.css";
115
116# logo to use
117$logo = "git-logo.png";
118
Christian Aistleitner21b3b3a2013-05-09 22:32:45 +0200119# the favicon
jhuntleyd7f53712012-08-01 14:19:46 -0400120$favicon = "git-favicon.png";
121----
122
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800123==== Configure & Restart Apache Web Server
jhuntleyd7f53712012-08-01 14:19:46 -0400124
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800125===== Configure Apache
jhuntleyd7f53712012-08-01 14:19:46 -0400126
127
128Link gitweb to `/var/www/gitweb`, check `/etc/gitweb.conf` if unsure of paths:
129
Michael Ochmannb99feab2016-07-06 14:10:22 +0200130----
David Pursehouse312e9732018-03-16 09:45:24 +0900131 sudo ln -s /usr/share/gitweb /var/www/gitweb
Michael Ochmannb99feab2016-07-06 14:10:22 +0200132----
jhuntleyd7f53712012-08-01 14:19:46 -0400133
134Add the gitweb directory to the Apache configuration by creating a "gitweb"
135file inside the Apache conf.d directory:
136
Michael Ochmannb99feab2016-07-06 14:10:22 +0200137----
David Pursehouse312e9732018-03-16 09:45:24 +0900138 touch /etc/apache/conf.d/gitweb
Michael Ochmannb99feab2016-07-06 14:10:22 +0200139----
jhuntleyd7f53712012-08-01 14:19:46 -0400140
141Add the following to /etc/apache/conf.d/gitweb:
142
143----
144Alias /gitweb /var/www/gitweb
145
146Options Indexes FollowSymlinks ExecCGI
147DirectoryIndex /cgi-bin/gitweb.cgi
148AllowOverride None
149----
150
Michael Ochmann8129ece2016-07-08 11:25:25 +0200151[NOTE]
152This may have already been added by yum/apt-get. If that's the case, leave as
jhuntleyd7f53712012-08-01 14:19:46 -0400153is.
154
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800155===== Restart the Apache Web Server
jhuntleyd7f53712012-08-01 14:19:46 -0400156
Michael Ochmannb99feab2016-07-06 14:10:22 +0200157----
David Pursehouse312e9732018-03-16 09:45:24 +0900158 sudo /etc/init.d/apache2 restart
Michael Ochmannb99feab2016-07-06 14:10:22 +0200159----
jhuntleyd7f53712012-08-01 14:19:46 -0400160
161Now you should be able to view your repository projects online:
162
163link:http://localhost/gitweb[http://localhost/gitweb]
164
165[[WindowsGitWeb]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800166==== Windows Installation
jhuntleyd7f53712012-08-01 14:19:46 -0400167
Dave Borowitza3d67882015-06-05 15:22:23 -0700168Instructions are available for installing the gitweb module distributed with
jhuntleyd7f53712012-08-01 14:19:46 -0400169MsysGit:
170
Marian Harbach34253372019-12-10 18:01:31 +0100171link:https://github.com/msysgit/msysgit/wiki/GitWeb[GitWeb,role=external,window=_blank]
jhuntleyd7f53712012-08-01 14:19:46 -0400172
173If you don't have Apache installed, you can download the appropriate build for
174Windows from link:http://www.apachelounge.com/download[apachelounge.org].
175
176After 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
Marian Harbach34253372019-12-10 18:01:31 +0100177account,role=external,window=_blank] to use with Apache.
jhuntleyd7f53712012-08-01 14:19:46 -0400178
179If you're still having difficulty setting up permissions, you may find this
180tech note useful for configuring Apache Service to run under another account.
Marian Harbach34253372019-12-10 18:01:31 +0100181You must grant the new account link:http://technet.microsoft.com/en-us/library/cc794944(WS.10).aspx["run as service",role=external,window=_blank] permission:
jhuntleyd7f53712012-08-01 14:19:46 -0400182
Dave Borowitza3d67882015-06-05 15:22:23 -0700183The gitweb version in msysgit is missing several important and required
jhuntleyd7f53712012-08-01 14:19:46 -0400184perl modules, including CGI.pm. The perl included with the msysgit distro 1.7.8
Marian Harbach34253372019-12-10 18:01:31 +0100185is 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,role=external,window=_blank]. You can
jhuntleyd7f53712012-08-01 14:19:46 -0400186verify by checking for perl modules. From an msys console, execute the
187following to check:
188
Michael Ochmannb99feab2016-07-06 14:10:22 +0200189----
David Pursehouse312e9732018-03-16 09:45:24 +0900190 perl -mCGI -mEncode -mFcntl -mFile::Find -mFile::Basename -e ""
Michael Ochmannb99feab2016-07-06 14:10:22 +0200191----
jhuntleyd7f53712012-08-01 14:19:46 -0400192
193You may encounter the following exception:
194
195----
196$ perl -mCGI -mEncode -mFcntl -mFile::Find -mFile::Basename -e ""
197Can't locate CGI.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8/msys
198/usr/lib/p erl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/msys
199/usr/lib/perl5/site_perl/5.8.8 /u sr/lib/perl5/site_perl .). BEGIN
200failed--compilation aborted.
201----
202
203If you're missing CGI.pm, you'll have to deploy the module to the msys
204environment: You will have to retrieve them from the 5.8.8 distro on :
205
Marian Harbach34253372019-12-10 18:01:31 +0100206http://strawberryperl.com/releases.html[role=external,window=_blank]
jhuntleyd7f53712012-08-01 14:19:46 -0400207
208File: strawberry-perl-5.8.8.3.zip
209
210contents: `bin/` `lib/` `site/`
211
212copy the contents of lib into `msysgit/lib/perl5/5.8.8` and overwrite existing files.
213
Dave Borowitza3d67882015-06-05 15:22:23 -0700214==== Enable Gitweb Integration
Shawn O. Pearce618dae22010-03-12 19:07:43 -0800215
216To enable the external gitweb integration, set
217link:config-gerrit.html#gitweb.url[gitweb.url] with the URL of your
218gitweb CGI.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800219
Shawn O. Pearce9743d0b2009-06-01 10:10:06 -0700220The CGI's `$projectroot` should be the same directory as
221gerrit.basePath, or a fairly current replica. If a replica is
Jonathan Nieder5758f182015-03-30 11:28:55 -0700222being used, ensure it uses a full mirror, so the `+refs/changes/*+`
Shawn O. Pearce9743d0b2009-06-01 10:10:06 -0700223namespace is available.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800224
jhuntleyd7f53712012-08-01 14:19:46 -0400225----
David Pursehousef7c63f62018-03-16 09:47:32 +0900226 git config -f $site_path/etc/gerrit.config gitweb.type gitweb
David Pursehouse312e9732018-03-16 09:45:24 +0900227 git config -f $site_path/etc/gerrit.config --unset gitweb.cgi
228 git config -f $site_path/etc/gerrit.config gitweb.url https://gitweb.corporation.com
jhuntleyd7f53712012-08-01 14:19:46 -0400229----
230
David Pursehouse312e9732018-03-16 09:45:24 +0900231If you're not following the traditional `\{projectName\}.git` project naming conventions,
jhuntleyd7f53712012-08-01 14:19:46 -0400232you will want to customize Gerrit to read them. Add the following:
233
234----
David Pursehouse312e9732018-03-16 09:45:24 +0900235 git config -f $site_path/etc/gerrit.config gitweb.type custom
236 git config -f $site_path/etc/gerrit.config gitweb.project ?p=\${project}\;a=summary
237 git config -f $site_path/etc/gerrit.config gitweb.revision ?p=\${project}\;a=commit\;h=\${commit}
238 git config -f $site_path/etc/gerrit.config gitweb.branch ?p=\${project}\;a=shortlog\;h=\${branch}
239 git config -f $site_path/etc/gerrit.config gitweb.roottree ?p=\${project}\;a=tree\;hb=\${commit}
240 git config -f $site_path/etc/gerrit.config gitweb.file ?p=\${project}\;hb=\${commit}\;f=\${file}
241 git config -f $site_path/etc/gerrit.config gitweb.filehistory ?p=\${project}\;a=history\;hb=\${branch}\;f=\${file}
jhuntleyd7f53712012-08-01 14:19:46 -0400242----
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800243
Shawn O. Pearcec5fed822009-11-17 16:10:10 -0800244After updating `'$site_path'/etc/gerrit.config`, the Gerrit server must
Shawn O. Pearced7ba11f2009-06-01 09:35:41 -0700245be restarted and clients must reload the host page to see the change.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800246
David Pursehouse8264ef72013-10-18 17:50:54 +0900247Note that when using a custom gitweb configuration, values must be
Colby Ranger79d4ebe2013-12-16 14:19:18 -0800248specified for all of the `project`, `revision`, `branch`, `roottree`,
249`file`, and `filehistory` settings, otherwise the configuration will
250not be used.
David Pursehouse8264ef72013-10-18 17:50:54 +0900251
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800252===== Access Control
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800253
254Gitweb access controls can be implemented using standard web server
255access controls. This isn't typically integrated with Gerrit's own
256access controls. Caution must be taken to ensure the controls are
257consistent if access needs to be restricted.
258
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800259===== Caching Gitweb
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800260
261If your repository set is large and you are expecting a lot
262of users, you may want to look at the caching forks used by
263high-traffic sites like kernel.org or repo.or.cz.
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700264
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800265=== Alternatives to gitweb
Shane Mc Cormack27868a42009-12-28 04:49:39 +0000266There are other alternatives to gitweb that can also be used with
267Gerrit, such as cgit.
268
269cgit can be used by specifying `gitweb.type` to be 'cgit'.
270
271It is also possible to define custom patterns.
272
Fredrik Luthandera6bb9512014-03-24 18:59:45 -0700273=== SEE ALSO
Shawn O. Pearced7ba11f2009-06-01 09:35:41 -0700274
Shawn O. Pearce8efb2a72009-08-18 19:45:33 -0700275* link:config-gerrit.html#gitweb[Section gitweb]
Marian Harbach34253372019-12-10 18:01:31 +0100276* link:http://git.zx2c4.com/cgit/about/[cgit,role=external,window=_blank]
Shawn O. Pearced7ba11f2009-06-01 09:35:41 -0700277
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700278GERRIT
279------
280Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700281
282SEARCHBOX
283---------