rjgit_grack 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +3 -2
- data/README.md +29 -3
- data/lib/rjgit_grack.rb +17 -4
- metadata +15 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3b6f0083eb09801ec9ab63c21d3cc61c0b4ee76
|
4
|
+
data.tar.gz: 35ba1805472c93b622aed689fbf90386b20b7369
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9ba14877655ed68438964b979f292a27a0be4e28643c20b310cfa1a98b680d702572c313b331cb6e3285728aeae945658210fb643db442c5c4262d5a62dba57
|
7
|
+
data.tar.gz: debe40b287309f60ec97fdaf595b73d10b142cd9e5edac3f5a60aef89bbfb3086330dc498818c5bda0d20f5b48d57e2306163a96f1f16bd0a455dbb10afad314
|
data/Gemfile
CHANGED
@@ -4,10 +4,11 @@ gem 'rake'
|
|
4
4
|
gem 'coveralls', require: false
|
5
5
|
|
6
6
|
group :test do
|
7
|
-
gem "
|
7
|
+
gem "minitest"
|
8
|
+
gem "rack-test"
|
8
9
|
gem "mocha"
|
9
10
|
gem "grack", :git => 'https://github.com/grackorg/grack'
|
10
11
|
gem "simplecov", :require => false
|
11
12
|
end
|
12
13
|
|
13
|
-
gemspec
|
14
|
+
gemspec
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
rjgit_grack
|
2
2
|
===========
|
3
3
|
[](http://badge.fury.io/rb/rjgit_grack)
|
4
|
-
[](https://travis-ci.org/grackorg/rjgit_grack.svg?branch=master)
|
5
5
|
[](https://gemnasium.com/grackorg/rjgit_grack)
|
6
6
|
|
7
7
|
Alternative Adapter for [grack](http://github.com/grackorg/grack); uses the [RJGit](http://github.com/repotag/rjgit) gem for a pure jruby interface to git repos. Together with Grack, this yields a pure jruby implementation of git's smart-http protocol.
|
@@ -14,7 +14,7 @@ Installation
|
|
14
14
|
Usage
|
15
15
|
===========
|
16
16
|
|
17
|
-
1. Get grack.
|
17
|
+
1. Get [grack](https://github.com/grackorgs/grack).
|
18
18
|
2. After requiring `rjgit_grack.rb`, you can tell Grack to use the `RJGitAdapter` by editing its configuration, for example:
|
19
19
|
|
20
20
|
```ruby
|
@@ -32,6 +32,32 @@ config = {
|
|
32
32
|
run Grack::App.new(config)
|
33
33
|
```
|
34
34
|
|
35
|
+
Hooks
|
36
|
+
===========
|
37
|
+
|
38
|
+
This adapter allows you to specify hooks to be called when receive operations (i.e. `git push` to the server) or upload operations (e.g. pulls, clones) are initiated. You can easily do this by passing an options hash to the `Grack::RJGitAdapter.new` call in the configuration, like so:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
:git_adapter_factory => ->{ Grack::RJGitAdapter.new({
|
42
|
+
:preReceive => Proc.new do |received_refs|
|
43
|
+
# This code is executed in the hook
|
44
|
+
puts received_refs
|
45
|
+
end
|
46
|
+
}
|
47
|
+
)}
|
48
|
+
```
|
49
|
+
|
50
|
+
You can specify the following hooks:
|
51
|
+
* `:preReceive` executed immediately before a receive-operation is performed. Yields an `Array` with `Hash` objects containing info about each ref that is about to be pushed, of the following form:
|
52
|
+
```ruby
|
53
|
+
{:ref_name => 'refs/heads/masters', :old_id => 'somesha1', :new_id => 'someothersha1', :type => "FAST_FORWARD", :result => "OK"}
|
54
|
+
```
|
55
|
+
* `:postReceive` executed after a receive-operation is completed. Yields an `Array` with `Hash` objects for each ref that was pushed, of the same form as above, plus a `:result` field. The result will be a `String`, and can have one of the values [defined by JGit](http://download.eclipse.org/jgit/site/4.3.0.201604071810-r/apidocs/index.html).
|
56
|
+
* `:preReceive` executed immediately before an upload-operation is performed, i.e. before data is sent to the client. Yields an `Array` of `String` object-id's (SHA1-hashes) already in common between client and server.
|
57
|
+
* `:postReceive` executed after an upload-operation to a client is complete. Returns an `org.eclipse.jgit.storage.pack.PackStatistics` object (see [here](http://download.eclipse.org/jgit/site/4.3.0.201604071810-r/apidocs/org/eclipse/jgit/storage/pack/PackStatistics.html)).
|
58
|
+
|
59
|
+
Note that JGit blocks all read and write operations on the repository until a hook is complete, so the hooks should only contain code that runs quickly (e.g. running workers or threads to perform the heavy work).
|
60
|
+
|
35
61
|
Specs
|
36
62
|
======
|
37
63
|
|
@@ -42,7 +68,7 @@ Run the specs:
|
|
42
68
|
Dependencies
|
43
69
|
===========
|
44
70
|
|
45
|
-
- [Grack](http://github.com/grackorg/grack) >= 0.1.0.
|
71
|
+
- [Grack](http://github.com/grackorg/grack) >= 0.1.0.pre2
|
46
72
|
- The [RJGit](http://github.com/repotag/rjgit) gem, which requires JRuby
|
47
73
|
|
48
74
|
License
|
data/lib/rjgit_grack.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require 'rjgit'
|
2
|
+
require 'hooks'
|
2
3
|
|
3
4
|
module Grack
|
4
5
|
|
5
6
|
class RJGitAdapter < GitAdapter
|
6
7
|
|
7
|
-
def initialize
|
8
|
+
def initialize(hooks = nil)
|
8
9
|
@repository_path = nil
|
10
|
+
@hooks = hooks
|
9
11
|
end
|
10
12
|
|
11
13
|
def handle_pack(pack_type, io_in, io_out, opts = {})
|
@@ -14,8 +16,9 @@ module Grack
|
|
14
16
|
RJGit::RJGitUploadPack.new(repo)
|
15
17
|
when 'git-receive-pack'
|
16
18
|
RJGit::RJGitReceivePack.new(repo)
|
17
|
-
|
18
|
-
return nil
|
19
|
+
end
|
20
|
+
return nil if pack.nil?
|
21
|
+
set_hooks(pack) if @hooks
|
19
22
|
if opts[:advertise_refs] then
|
20
23
|
io_out.write advertisement_prefix(pack_type)
|
21
24
|
result = pack.advertise_refs
|
@@ -50,6 +53,16 @@ module Grack
|
|
50
53
|
def repo
|
51
54
|
RJGit::Repo.new(repository_path)
|
52
55
|
end
|
56
|
+
|
57
|
+
def set_hooks(pack)
|
58
|
+
if pack.is_a?(RJGit::RJGitUploadPack)
|
59
|
+
pack.jpack.setPostUploadHook(Grack::Hooks::PostUploadHook.new(@hooks[:postUpload])) if @hooks[:postUpload]
|
60
|
+
pack.jpack.setPreUploadHook(Grack::Hooks::PreUploadHook.new(@hooks[:preUpload])) if @hooks[:preUpload]
|
61
|
+
elsif pack.is_a?(RJGit::RJGitReceivePack)
|
62
|
+
pack.jpack.setPostReceiveHook(Grack::Hooks::PostReceiveHook.new(@hooks[:postReceive])) if @hooks[:postReceive]
|
63
|
+
pack.jpack.setPreReceiveHook(Grack::Hooks::PreReceiveHook.new(@hooks[:preReceive])) if @hooks[:preReceive]
|
64
|
+
end
|
65
|
+
end
|
53
66
|
|
54
67
|
end
|
55
68
|
|
metadata
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjgit_grack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dawa Ometto
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rjgit
|
15
|
-
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
|
-
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
23
|
requirements:
|
22
24
|
- - ~>
|
23
25
|
- !ruby/object:Gem::Version
|
24
26
|
version: '4.0'
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
description: Alternative Adapter for grack; uses the RJGit gem for a pure jruby interface
|
28
|
+
to git repos. Together with Grack, this yields a pure JRuby implementation of git's
|
29
|
+
smart-http protocol.
|
28
30
|
email: d.ometto@gmail.com
|
29
31
|
executables: []
|
30
32
|
extensions: []
|
@@ -38,7 +40,7 @@ homepage: http://github.com/grackorg/rjgit_grack
|
|
38
40
|
licenses:
|
39
41
|
- MIT
|
40
42
|
metadata: {}
|
41
|
-
post_install_message:
|
43
|
+
post_install_message:
|
42
44
|
rdoc_options: []
|
43
45
|
require_paths:
|
44
46
|
- lib
|
@@ -53,9 +55,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
55
|
- !ruby/object:Gem::Version
|
54
56
|
version: '0'
|
55
57
|
requirements: []
|
56
|
-
rubyforge_project:
|
57
|
-
rubygems_version: 2.
|
58
|
-
signing_key:
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 2.2.2
|
60
|
+
signing_key:
|
59
61
|
specification_version: 4
|
60
62
|
summary: Adapts grack (http://github.com/grackorg/grack) to use JGit.
|
61
63
|
test_files: []
|
64
|
+
has_rdoc:
|