-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathREADME.md.erb
194 lines (142 loc) · 5.78 KB
/
README.md.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<%
# This is the template file for README.md. The gemspec details are available
# within the _spec_ attribute, and all methods defined in the Rakefile are
# also available. The Rakefile will use this file to regenerate README.md
# when necessary.
-%>
[](http://badge.fury.io/rb/grack)
[](https://travis-ci.org/grackorg/grack)
[](https://coveralls.io/github/grackorg/grack?branch=master)
[](https://gemnasium.com/grackorg/grack)
# Grack - Ruby/Rack Git Smart HTTP Server Handler
<%= word_wrap(spec.summary) %>
## Links
* Homepage :: <%= spec.homepage %>
* Source :: https://github.com/grackorg/grack.git
## Description
<%= spec.description -%>
The default git-http-backend only runs as a CGI script, and specifically is
only targeted for Apache 2.x usage (it requires PATH_INFO to be set and
specifically formatted). So, instead of trying to get it to work with other
CGI capable webservers (Lighttpd, etc), we can get it running on nearly every
major and minor webserver out there by making it Rack capable. Rack
applications can run with the following handlers:
* CGI
* FCGI
* Mongrel (and EventedMongrel and SwiftipliedMongrel)
* WEBrick
* SCGI
* LiteSpeed
* Thin
These web servers include Rack handlers in their distributions:
* Ebb
* Fuzed
* Phusion Passenger (which is mod_rack for Apache and for nginx)
* Unicorn
With [Warbler](http://caldersphere.rubyforge.org/warbler/classes/Warbler.html),
and JRuby, we can also generate a WAR file that can be deployed in any Java web
application server (Tomcat, Glassfish, Websphere, JBoss, etc).
By default, Grack uses calls to git on the system to implement Smart HTTP.
Since the git-http-backend is really just a simple wrapper for the upload-pack
and receive-pack processes with the '--stateless-rpc' option, this does not
actually re-implement very much. However, it is possible to use a different
backend by specifying a different Adapter. See below for a list.
Note that while it is technically possible to host non-bare repositories with
this gem, it is discouraged. The only somewhat safe option is to serve such a
repository as read-only since there is a greater risk of arbitrary filesystem
traversal when a checkout tree must be traversed to reach the repository
administrative area (`.git` directory). Additionally, any recent version of Git
prevents pushes into non-bare repositories by default since pushing into the
currently checked out branch can effectively "break" the checkout tree.
## Synopsis
In `config.ru`:
```ruby
require 'grack/app'
require 'grack/git_adapter'
config = {
:root => '/path/to/bare/repositories',
:allow_push => true,
:allow_pull => true,
:git_adapter_factory => ->{ Grack::GitAdapter.new }
}
run Grack::App.new(config)
```
Then run:
```sh
$ bundle exec rackup --host 127.0.0.1 --port 8080 config.ru
$ git clone http://localhost:8080/your-repository.git
```
### Git Adapters
Grack makes calls to the git binary through the GitAdapter abstraction class.
Grack can be made to use a different backend by specifying a call-able object,
such as a lambda, in Grack's configuration that provides new adapter instances
per request. For example:
```ruby
Grack::App.new(:git_adapter_factory => ->{ MyAdapter.new })
```
Alternative adapters available:
* [rjgit_grack](http://github.com/grackorg/rjgit_grack) lets Grack use the
[RJGit](http://github.com/repotag/rjgit) gem to implement Smart HTTP in pure
JRuby.
### Developing Adapters
Adapters are abstraction classes that handle the actual implementation of the
Smart HTTP protocol (advertising refs, uploading and receiving packfiles). Such
abstraction classes must have the following methods:
```ruby
MyAdapter.repository_path=(repository_path)
MyAdapter.exist?
MyAdapter.handle_pack(kind, io_in, io_out, opts = {})
MyAdapter.file(path)
MyAdapter.update_server_info
MyAdapter.allow_push?
MyAdapter.allow_pull?
```
See `Grack::GitAdapter` for more detailed documentation and an example
implementation.
## Features
* Supports Git Smart HTTP protocol.
* Supports Git Basic HTTP protocol.
* Limits push/pull access globally and per-repository.
* Thread safe operation.
### Hooks
By default, grack doesn't support git hooks. This is because the default GitAdapter directly streams the requests to the `git-receive-pack` and `git-upload-pack` processes. However, alternative adapters may implement hooks.
Adapters that support hooks:
* [rjgit_grack](http://github.com/grackorg/rjgit_grack)
## Known Bugs/Limitations
* Will likely block fully evented web servers when using the stock Git adapter.
## Runtime Requirements
* Ruby >=1.9.3
* Git >=1.7 (if using the included Git adapter)
<% spec.runtime_dependencies.each do |dependency| -%>
* <%= dependency %>
<% end -%>
## Development Requirements
* All runtime requirements
<% spec.development_dependencies.each do |dependency| -%>
* <%= dependency.name %> (<%= dependency.requirement %>)
<% end -%>
## Contributing
Contributions for bug fixes, documentation, extensions, tests, etc. are
encouraged.
1. Clone the repository.
2. Fix a bug or add a feature.
3. Add tests for the fix or feature.
4. Make a pull request.
## Development
After checking out the source, run:
```sh
$ bundle install
$ bundle exec rake test yard
```
This will install all dependencies, run the tests/specs, and generate the
documentation.
## Authors
Thanks to all contributors. Without your help this project would not exist.
<% spec.authors.zip(spec.email).each do |author, email| -%>
* <%= author %> :: <%= email %>
<% end -%>
## License
```
<%= File.read('LICENSE') -%>
```
<% # vim: set ts=2 sw=2 et: -%>