blob: 7ba15b8a2e319f194e764314a8a11b7af2a6a384 [file] [log] [blame]
jhuntleyd7f53712012-08-01 14:19:46 -04001Gitweb Integration
2------------------
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
Shawn O. Pearce618dae22010-03-12 19:07:43 -08008Internal/Managed gitweb
jhuntleyd7f53712012-08-01 14:19:46 -04009~~~~~~~~~~~~~~~~~~~~~~~
Shawn O. Pearce618dae22010-03-12 19:07:43 -080010
11In the internal configuration, Gerrit inspects the request, enforces
12its project level access controls, and directly executes `gitweb.cgi`
13if the user is authorized to view the page.
14
15To enable the internal configuration, set
16link:config-gerrit.html#gitweb.cgi[gitweb.cgi] with the path of the
17installed CGI. This defaults to `/usr/lib/cgi-bin/gitweb.cgi`,
18which is a common installation path for the 'gitweb' package on
19Linux distributions.
20
21====
22 git config --file $site_path/etc/gerrit.config gitweb.cgi /usr/lib/cgi-bin/gitweb.cgi
Piotr Sikora6a9d47e2011-02-27 21:22:32 +000023 git config --file $site_path/etc/gerrit.config --unset gitweb.url
24====
25
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
32====
33 git config --file $site_path/etc/gerrit.config gitweb.cgi /usr/lib/cgi-bin/gitweb.cgi
34 git config --file $site_path/etc/gerrit.config gitweb.url /pretty/path/to/gitweb
Shawn O. Pearce618dae22010-03-12 19:07:43 -080035====
36
37After updating `'$site_path'/etc/gerrit.config`, the Gerrit server must
38be restarted and clients must reload the host page to see the change.
39
Shawn O. Pearce544220c2010-03-13 17:39:35 -080040Configuration
jhuntleyd7f53712012-08-01 14:19:46 -040041^^^^^^^^^^^^^
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
Shawn O. Pearcea57697b2010-03-13 18:23:47 -080048Logo and CSS
jhuntleyd7f53712012-08-01 14:19:46 -040049^^^^^^^^^^^^
Shawn O. Pearcea57697b2010-03-13 18:23:47 -080050
51If the package-manager installed CGI (`/usr/lib/cgi-bin/gitweb.cgi`)
52is being used, the stock CSS and logo files will be served from
53either `/usr/share/gitweb` or `/var/www`.
54
55Otherwise, Gerrit expects `gitweb.css` and `git-logo.png` to be found
56in the same directory as the CGI script itself. This matches with
57the default source code distribution, and most custom installations.
58
Shawn O. Pearce618dae22010-03-12 19:07:43 -080059Access Control
jhuntleyd7f53712012-08-01 14:19:46 -040060^^^^^^^^^^^^^^
Shawn O. Pearce618dae22010-03-12 19:07:43 -080061
62Access controls for internally managed gitweb page views are enforced
63using the standard project READ +1 permission.
64
Shawn O. Pearce618dae22010-03-12 19:07:43 -080065External/Unmanaged gitweb
jhuntleyd7f53712012-08-01 14:19:46 -040066~~~~~~~~~~~~~~~~~~~~~~~~~
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]]
73Linux Installation
74^^^^^^^^^^^^^^^^^^
75
76Install GitWeb
77++++++++++++++
78
79On Ubuntu:
80
81====
82 sudo apt-get install gitweb
83====
84
85With Yum:
86
87====
88 $ yum install gitweb
89====
90
91Configure GitWeb
92++++++++++++++++
93
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
123Configure & Restart Apache Web Server
124^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
125
126Configure Apache
127++++++++++++++++
128
129
130Link gitweb to `/var/www/gitweb`, check `/etc/gitweb.conf` if unsure of paths:
131
132====
133 $ sudo ln -s /usr/share/gitweb /var/www/gitweb
134====
135
136Add the gitweb directory to the Apache configuration by creating a "gitweb"
137file inside the Apache conf.d directory:
138
139====
140 $ touch /etc/apache/conf.d/gitweb
141====
142
143Add the following to /etc/apache/conf.d/gitweb:
144
145----
146Alias /gitweb /var/www/gitweb
147
148Options Indexes FollowSymlinks ExecCGI
149DirectoryIndex /cgi-bin/gitweb.cgi
150AllowOverride None
151----
152
153*NOTE* This may have already been added by yum/apt-get. If that's the case, leave as
154is.
155
156Restart the Apache Web Server
157+++++++++++++++++++++++++++++
158
159====
160$ sudo /etc/init.d/apache2 restart
161====
162
163Now you should be able to view your repository projects online:
164
165link:http://localhost/gitweb[http://localhost/gitweb]
166
167[[WindowsGitWeb]]
168Windows Installation
169^^^^^^^^^^^^^^^^^^^^
170
171Instructions are available for installing the GitWeb module distributed with
172MsysGit:
173
174link:https://github.com/msysgit/msysgit/wiki/GitWeb[GitWeb]
175
176If you don't have Apache installed, you can download the appropriate build for
177Windows from link:http://www.apachelounge.com/download[apachelounge.org].
178
179After 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
180account] to use with Apache.
181
182If you're still having difficulty setting up permissions, you may find this
183tech note useful for configuring Apache Service to run under another account.
184You must grant the new account link:http://technet.microsoft.com/en-us/library/cc794944(WS.10).aspx["run as service"] permission:
185
186The GitWeb version in msysgit is missing several important and required
187perl modules, including CGI.pm. The perl included with the msysgit distro 1.7.8
188is 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
189verify by checking for perl modules. From an msys console, execute the
190following to check:
191
192====
193$ perl -mCGI -mEncode -mFcntl -mFile::Find -mFile::Basename -e ""
194====
195
196You may encounter the following exception:
197
198----
199$ perl -mCGI -mEncode -mFcntl -mFile::Find -mFile::Basename -e ""
200Can't locate CGI.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8/msys
201/usr/lib/p erl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/msys
202/usr/lib/perl5/site_perl/5.8.8 /u sr/lib/perl5/site_perl .). BEGIN
203failed--compilation aborted.
204----
205
206If you're missing CGI.pm, you'll have to deploy the module to the msys
207environment: You will have to retrieve them from the 5.8.8 distro on :
208
209http://strawberryperl.com/releases.html
210
211File: strawberry-perl-5.8.8.3.zip
212
213contents: `bin/` `lib/` `site/`
214
215copy the contents of lib into `msysgit/lib/perl5/5.8.8` and overwrite existing files.
216
217Enable GitWeb Integration
218^^^^^^^^^^^^^^^^^^^^^^^^^
Shawn O. Pearce618dae22010-03-12 19:07:43 -0800219
220To enable the external gitweb integration, set
221link:config-gerrit.html#gitweb.url[gitweb.url] with the URL of your
222gitweb CGI.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800223
Shawn O. Pearce9743d0b2009-06-01 10:10:06 -0700224The CGI's `$projectroot` should be the same directory as
225gerrit.basePath, or a fairly current replica. If a replica is
226being used, ensure it uses a full mirror, so the `refs/changes/*`
227namespace is available.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800228
jhuntleyd7f53712012-08-01 14:19:46 -0400229----
230$ git config -f $site_path/etc/gerrit.config gitweb.cgi $PATH_TO_GITWEB/gitweb.cgi
231$ git config -f $site_path/etc/gerrit.config gitweb.url https://gitweb.corporation.com
232----
233
234If you're not following the traditional \{projectName\}.git project naming conventions,
235you will want to customize Gerrit to read them. Add the following:
236
237----
238$ git config -f $site_path/etc/gerrit.config gitweb.type custom
239$ git config -f $site_path/etc/gerrit.config gitweb.project ?p=\${project}\;a=summary
240$ git config -f $site_path/etc/gerrit.config gitweb.revision ?p=\${project}\;a=commit\;h=\${commit}
241$ git config -f $site_path/etc/gerrit.config gitweb.branch ?p=\${project}\;a=shortlog\;h=\${branch}
242$ git config -f $site_path/etc/gerrit.config gitweb.filehistory ?p=\${project}\;a=history\;hb=\${branch}\;f=\${file}
243----
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800244
Shawn O. Pearcec5fed822009-11-17 16:10:10 -0800245After updating `'$site_path'/etc/gerrit.config`, the Gerrit server must
Shawn O. Pearced7ba11f2009-06-01 09:35:41 -0700246be restarted and clients must reload the host page to see the change.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800247
248Access Control
jhuntleyd7f53712012-08-01 14:19:46 -0400249++++++++++++++
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800250
251Gitweb access controls can be implemented using standard web server
252access controls. This isn't typically integrated with Gerrit's own
253access controls. Caution must be taken to ensure the controls are
254consistent if access needs to be restricted.
255
256Caching Gitweb
jhuntleyd7f53712012-08-01 14:19:46 -0400257++++++++++++++
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800258
259If your repository set is large and you are expecting a lot
260of users, you may want to look at the caching forks used by
261high-traffic sites like kernel.org or repo.or.cz.
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700262
Shane Mc Cormack27868a42009-12-28 04:49:39 +0000263Alternatives to gitweb
Shawn O. Pearce618dae22010-03-12 19:07:43 -0800264~~~~~~~~~~~~~~~~~~~~~~
Shane Mc Cormack27868a42009-12-28 04:49:39 +0000265There are other alternatives to gitweb that can also be used with
266Gerrit, such as cgit.
267
268cgit can be used by specifying `gitweb.type` to be 'cgit'.
269
270It is also possible to define custom patterns.
271
Shawn O. Pearced7ba11f2009-06-01 09:35:41 -0700272See Also
jhuntleyd7f53712012-08-01 14:19:46 -0400273~~~~~~~~
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]
Shane Mc Cormack27868a42009-12-28 04:49:39 +0000276* link:http://hjemli.net/git/cgit/[cgit]
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]