Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
GIt Smart HTTP Server Rack Implementation
Ruby
branch: master

This branch is 4 commits ahead, 45 commits behind schacon:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
lib
tests
.gitignore
.gitmodules
README.md
Rakefile
grack.gemspec
install.txt

README.md

Fork info

This fork packages grack as a gem which can then be used as a Rails middleware. Documentation on grack usage can be found in the original README.

Using it as a Rails Middleware

Installation

Via Bundler

gem 'grack', require: 'git_http'

Create `middleware/git_handler.rb

class GitHandler
  GIT_REQUEST = %r{^/projects/(\w+)/code.git(/.*)}

  def initialize( app )
    @app = app
    @git_provider = GitHttp::App.new
    @git_provider.set_config({
      :project_root => Settings.repo_home,
      :upload_pack => true,
      :receive_pack => true
    })
  end

  def call( env )
    if m = GIT_REQUEST.match(env['PATH_INFO'])
      env['PATH_INFO'] = "/projects/#{m[1]}/code.git#{m[2]}"
      @git_provider.call(env)
    else
      @app.call(env)
    end
  end

end

Add it to application.rb

config.autoload_paths += %W(#{config.root}/middleware)
config.middleware.use "GitHandler"

Example usage

If:

  • Settings.repo_home is /Users/akshayrawat/repo_home/
  • /Users/akshayrawat/repo_home/projects/1/code.git exists
  • Server is running at http://localhost:3000

You should be able to git clone http://localhost:3000/projects/1/code.git.

License

(The MIT License)

Copyright (c) 2009 Scott Chacon <schacon@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.
Something went wrong with that request. Please try again.