Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 1 | == Gitweb Integration |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 2 | |
Shawn O. Pearce | 618dae2 | 2010-03-12 19:07:43 -0800 | [diff] [blame] | 3 | Gerrit Code Review can manage and generate hyperlinks to gitweb, |
| 4 | allowing users to jump from Gerrit content to the same information, |
| 5 | but shown by gitweb. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 6 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 7 | === Internal/Managed gitweb |
Shawn O. Pearce | 618dae2 | 2010-03-12 19:07:43 -0800 | [diff] [blame] | 8 | |
| 9 | In the internal configuration, Gerrit inspects the request, enforces |
| 10 | its project level access controls, and directly executes `gitweb.cgi` |
| 11 | if the user is authorized to view the page. |
| 12 | |
| 13 | To enable the internal configuration, set |
| 14 | link:config-gerrit.html#gitweb.cgi[gitweb.cgi] with the path of the |
| 15 | installed CGI. This defaults to `/usr/lib/cgi-bin/gitweb.cgi`, |
| 16 | which is a common installation path for the 'gitweb' package on |
| 17 | Linux distributions. |
| 18 | |
| 19 | ==== |
| 20 | git config --file $site_path/etc/gerrit.config gitweb.cgi /usr/lib/cgi-bin/gitweb.cgi |
Piotr Sikora | 6a9d47e | 2011-02-27 21:22:32 +0000 | [diff] [blame] | 21 | git config --file $site_path/etc/gerrit.config --unset gitweb.url |
| 22 | ==== |
| 23 | |
| 24 | Alternatively, if Gerrit is served behind reverse proxy, it can |
| 25 | generate different URLs for gitweb's links (they need to be |
| 26 | rewritten to `<gerrit>/gitweb?args` on the web server). This allows |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 27 | for serving gitweb under a different URL than the Gerrit instance. |
Piotr Sikora | 6a9d47e | 2011-02-27 21:22:32 +0000 | [diff] [blame] | 28 | To 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. Pearce | 618dae2 | 2010-03-12 19:07:43 -0800 | [diff] [blame] | 33 | ==== |
| 34 | |
| 35 | After updating `'$site_path'/etc/gerrit.config`, the Gerrit server must |
| 36 | be restarted and clients must reload the host page to see the change. |
| 37 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 38 | ==== Configuration |
Shawn O. Pearce | 544220c | 2010-03-13 17:39:35 -0800 | [diff] [blame] | 39 | |
| 40 | Most of the gitweb configuration file is handled automatically |
| 41 | by Gerrit Code Review. Site specific overrides can be placed in |
| 42 | `'$site_path'/etc/gitweb_config.perl`, as this file is loaded as |
| 43 | part of the generated configuration file. |
| 44 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 45 | ==== Logo and CSS |
Shawn O. Pearce | a57697b | 2010-03-13 18:23:47 -0800 | [diff] [blame] | 46 | |
| 47 | If the package-manager installed CGI (`/usr/lib/cgi-bin/gitweb.cgi`) |
| 48 | is being used, the stock CSS and logo files will be served from |
| 49 | either `/usr/share/gitweb` or `/var/www`. |
| 50 | |
| 51 | Otherwise, Gerrit expects `gitweb.css` and `git-logo.png` to be found |
| 52 | in the same directory as the CGI script itself. This matches with |
| 53 | the default source code distribution, and most custom installations. |
| 54 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 55 | ==== Access Control |
Shawn O. Pearce | 618dae2 | 2010-03-12 19:07:43 -0800 | [diff] [blame] | 56 | |
| 57 | Access controls for internally managed gitweb page views are enforced |
| 58 | using the standard project READ +1 permission. |
| 59 | |
Warren Turkal | f8101aa | 2013-12-11 15:56:53 -0800 | [diff] [blame] | 60 | Also, in order for a user to be able to view any gitweb information for a |
David Pursehouse | 659860f | 2013-12-16 14:50:04 +0900 | [diff] [blame] | 61 | project, the user must be able to read all references (including |
Warren Turkal | f8101aa | 2013-12-11 15:56:53 -0800 | [diff] [blame] | 62 | refs/meta/config, refs/meta/dashboards/*, etc.). If you have exclusive read |
| 63 | permissions for any references, make sure to include all parties that should be |
| 64 | able to read the gitweb info for any of the branches in that project. |
| 65 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 66 | === External/Unmanaged gitweb |
Shawn O. Pearce | 618dae2 | 2010-03-12 19:07:43 -0800 | [diff] [blame] | 67 | |
jhuntley | d7f5371 | 2012-08-01 14:19:46 -0400 | [diff] [blame] | 68 | For the external configuration, gitweb runs under the control of an |
| 69 | external web server, and Gerrit access controls are not enforced. Gerrit |
| 70 | provides configuration parameters for integration with GitWeb. |
| 71 | |
| 72 | [[linuxGitWeb]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 73 | ==== Linux Installation |
jhuntley | d7f5371 | 2012-08-01 14:19:46 -0400 | [diff] [blame] | 74 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 75 | ===== Install GitWeb |
jhuntley | d7f5371 | 2012-08-01 14:19:46 -0400 | [diff] [blame] | 76 | |
| 77 | On Ubuntu: |
| 78 | |
| 79 | ==== |
| 80 | sudo apt-get install gitweb |
| 81 | ==== |
| 82 | |
| 83 | With Yum: |
| 84 | |
| 85 | ==== |
| 86 | $ yum install gitweb |
| 87 | ==== |
| 88 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 89 | ===== Configure GitWeb |
jhuntley | d7f5371 | 2012-08-01 14:19:46 -0400 | [diff] [blame] | 90 | |
| 91 | |
| 92 | Update `/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 Aistleitner | 21b3b3a | 2013-05-09 22:32:45 +0200 | [diff] [blame] | 116 | # the favicon |
jhuntley | d7f5371 | 2012-08-01 14:19:46 -0400 | [diff] [blame] | 117 | $favicon = "git-favicon.png"; |
| 118 | ---- |
| 119 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 120 | ==== Configure & Restart Apache Web Server |
jhuntley | d7f5371 | 2012-08-01 14:19:46 -0400 | [diff] [blame] | 121 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 122 | ===== Configure Apache |
jhuntley | d7f5371 | 2012-08-01 14:19:46 -0400 | [diff] [blame] | 123 | |
| 124 | |
| 125 | Link 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 | |
| 131 | Add the gitweb directory to the Apache configuration by creating a "gitweb" |
| 132 | file inside the Apache conf.d directory: |
| 133 | |
| 134 | ==== |
| 135 | $ touch /etc/apache/conf.d/gitweb |
| 136 | ==== |
| 137 | |
| 138 | Add the following to /etc/apache/conf.d/gitweb: |
| 139 | |
| 140 | ---- |
| 141 | Alias /gitweb /var/www/gitweb |
| 142 | |
| 143 | Options Indexes FollowSymlinks ExecCGI |
| 144 | DirectoryIndex /cgi-bin/gitweb.cgi |
| 145 | AllowOverride None |
| 146 | ---- |
| 147 | |
| 148 | *NOTE* This may have already been added by yum/apt-get. If that's the case, leave as |
| 149 | is. |
| 150 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 151 | ===== Restart the Apache Web Server |
jhuntley | d7f5371 | 2012-08-01 14:19:46 -0400 | [diff] [blame] | 152 | |
| 153 | ==== |
| 154 | $ sudo /etc/init.d/apache2 restart |
| 155 | ==== |
| 156 | |
| 157 | Now you should be able to view your repository projects online: |
| 158 | |
| 159 | link:http://localhost/gitweb[http://localhost/gitweb] |
| 160 | |
| 161 | [[WindowsGitWeb]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 162 | ==== Windows Installation |
jhuntley | d7f5371 | 2012-08-01 14:19:46 -0400 | [diff] [blame] | 163 | |
| 164 | Instructions are available for installing the GitWeb module distributed with |
| 165 | MsysGit: |
| 166 | |
| 167 | link:https://github.com/msysgit/msysgit/wiki/GitWeb[GitWeb] |
| 168 | |
| 169 | If you don't have Apache installed, you can download the appropriate build for |
| 170 | Windows from link:http://www.apachelounge.com/download[apachelounge.org]. |
| 171 | |
| 172 | After 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 |
| 173 | account] to use with Apache. |
| 174 | |
| 175 | If you're still having difficulty setting up permissions, you may find this |
| 176 | tech note useful for configuring Apache Service to run under another account. |
| 177 | You must grant the new account link:http://technet.microsoft.com/en-us/library/cc794944(WS.10).aspx["run as service"] permission: |
| 178 | |
| 179 | The GitWeb version in msysgit is missing several important and required |
| 180 | perl modules, including CGI.pm. The perl included with the msysgit distro 1.7.8 |
| 181 | is 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 |
| 182 | verify by checking for perl modules. From an msys console, execute the |
| 183 | following to check: |
| 184 | |
| 185 | ==== |
| 186 | $ perl -mCGI -mEncode -mFcntl -mFile::Find -mFile::Basename -e "" |
| 187 | ==== |
| 188 | |
| 189 | You may encounter the following exception: |
| 190 | |
| 191 | ---- |
| 192 | $ perl -mCGI -mEncode -mFcntl -mFile::Find -mFile::Basename -e "" |
| 193 | Can'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 |
| 196 | failed--compilation aborted. |
| 197 | ---- |
| 198 | |
| 199 | If you're missing CGI.pm, you'll have to deploy the module to the msys |
| 200 | environment: You will have to retrieve them from the 5.8.8 distro on : |
| 201 | |
| 202 | http://strawberryperl.com/releases.html |
| 203 | |
| 204 | File: strawberry-perl-5.8.8.3.zip |
| 205 | |
| 206 | contents: `bin/` `lib/` `site/` |
| 207 | |
| 208 | copy the contents of lib into `msysgit/lib/perl5/5.8.8` and overwrite existing files. |
| 209 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 210 | ==== Enable GitWeb Integration |
Shawn O. Pearce | 618dae2 | 2010-03-12 19:07:43 -0800 | [diff] [blame] | 211 | |
| 212 | To enable the external gitweb integration, set |
| 213 | link:config-gerrit.html#gitweb.url[gitweb.url] with the URL of your |
| 214 | gitweb CGI. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 215 | |
Shawn O. Pearce | 9743d0b | 2009-06-01 10:10:06 -0700 | [diff] [blame] | 216 | The CGI's `$projectroot` should be the same directory as |
| 217 | gerrit.basePath, or a fairly current replica. If a replica is |
| 218 | being used, ensure it uses a full mirror, so the `refs/changes/*` |
| 219 | namespace is available. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 220 | |
jhuntley | d7f5371 | 2012-08-01 14:19:46 -0400 | [diff] [blame] | 221 | ---- |
| 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 | |
| 226 | If you're not following the traditional \{projectName\}.git project naming conventions, |
| 227 | you 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 Ranger | 79d4ebe | 2013-12-16 14:19:18 -0800 | [diff] [blame] | 234 | $ 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} |
jhuntley | d7f5371 | 2012-08-01 14:19:46 -0400 | [diff] [blame] | 236 | $ git config -f $site_path/etc/gerrit.config gitweb.filehistory ?p=\${project}\;a=history\;hb=\${branch}\;f=\${file} |
| 237 | ---- |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 238 | |
Shawn O. Pearce | c5fed82 | 2009-11-17 16:10:10 -0800 | [diff] [blame] | 239 | After updating `'$site_path'/etc/gerrit.config`, the Gerrit server must |
Shawn O. Pearce | d7ba11f | 2009-06-01 09:35:41 -0700 | [diff] [blame] | 240 | be restarted and clients must reload the host page to see the change. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 241 | |
David Pursehouse | 8264ef7 | 2013-10-18 17:50:54 +0900 | [diff] [blame] | 242 | Note that when using a custom gitweb configuration, values must be |
Colby Ranger | 79d4ebe | 2013-12-16 14:19:18 -0800 | [diff] [blame] | 243 | specified for all of the `project`, `revision`, `branch`, `roottree`, |
| 244 | `file`, and `filehistory` settings, otherwise the configuration will |
| 245 | not be used. |
David Pursehouse | 8264ef7 | 2013-10-18 17:50:54 +0900 | [diff] [blame] | 246 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 247 | ===== Access Control |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 248 | |
| 249 | Gitweb access controls can be implemented using standard web server |
| 250 | access controls. This isn't typically integrated with Gerrit's own |
| 251 | access controls. Caution must be taken to ensure the controls are |
| 252 | consistent if access needs to be restricted. |
| 253 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 254 | ===== Caching Gitweb |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 255 | |
| 256 | If your repository set is large and you are expecting a lot |
| 257 | of users, you may want to look at the caching forks used by |
| 258 | high-traffic sites like kernel.org or repo.or.cz. |
Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 259 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 260 | === Alternatives to gitweb |
Shane Mc Cormack | 27868a4 | 2009-12-28 04:49:39 +0000 | [diff] [blame] | 261 | There are other alternatives to gitweb that can also be used with |
| 262 | Gerrit, such as cgit. |
| 263 | |
| 264 | cgit can be used by specifying `gitweb.type` to be 'cgit'. |
| 265 | |
| 266 | It is also possible to define custom patterns. |
| 267 | |
Fredrik Luthander | a6bb951 | 2014-03-24 18:59:45 -0700 | [diff] [blame] | 268 | === SEE ALSO |
Shawn O. Pearce | d7ba11f | 2009-06-01 09:35:41 -0700 | [diff] [blame] | 269 | |
Shawn O. Pearce | 8efb2a7 | 2009-08-18 19:45:33 -0700 | [diff] [blame] | 270 | * link:config-gerrit.html#gitweb[Section gitweb] |
Shane Mc Cormack | 27868a4 | 2009-12-28 04:49:39 +0000 | [diff] [blame] | 271 | * link:http://hjemli.net/git/cgit/[cgit] |
Shawn O. Pearce | d7ba11f | 2009-06-01 09:35:41 -0700 | [diff] [blame] | 272 | |
Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 273 | GERRIT |
| 274 | ------ |
| 275 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 276 | |
| 277 | SEARCHBOX |
| 278 | --------- |