0.0
No commit activity in last 3 years
No release in over 3 years
Alternative Adapter for grack; uses the 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.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 5.6
 Project Readme

rjgit_grack

Gem Version Build Status Dependency Status

Alternative Adapter for grack; uses the 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.

Installation

gem install rjgit_grack

Usage

  1. Get grack.
  2. add grack and rjgit_grack to your Gemfile
  3. You can tell Grack to use the RJGitAdapter by editing its configuration, for example:
require 'grack/app'
require 'grack/rjgit_adapter'

config = {
  :root => '/tmp/',
  :allow_push => true,
  :allow_pull => true,
  :git_adapter_factory => ->{ Grack::RJGitAdapter.new }
}

run Grack::App.new(config)

Hooks

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:

  :git_adapter_factory => ->{ Grack::RJGitAdapter.new({
    :preReceive => Proc.new do |received_refs|
      # This code is executed in the hook
      puts received_refs
    end
    }
  )}

You can specify the following hooks:

  • :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:
      {:ref_name => 'refs/heads/masters', :old_id => 'somesha1', :new_id => 'someothersha1', :type => "FAST_FORWARD"}
    
  • :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.
  • :preUpload 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.
  • :postUpload executed after an upload-operation to a client is complete. Returns an org.eclipse.jgit.storage.pack.PackStatistics object (see here).

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).

Specs

Run the specs:

rake

Dependencies

  • Grack >= 0.1.0.pre2
  • The RJGit gem, which requires JRuby

License

(The MIT License)

Copyright (c) 2013 Dawa Ometto <d.ometto@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.