Rack::Git::Revision

Rack::GitRevision is a git revision http interface for rack applications.

Usage

# Gemfile
gem 'rack-git-revision'

And then execute:

# config.ru
use Rack::GitRevision
$ curl localhost:3000/dev/revision
=> 7424ba3207725cd1321f06949330b5f531f9af72

Change Url path

use Rack::GitRevision, path: '/git_revision'

for capistrano3 (working on Rails)

use Rack::GitRevision, {
  git_path: Rails.env.production? ? File.expand_path('../../repo/.git', __FILE__) : nil
}
run Rails.application

Options

Defaults

@options = {
  path: '/dev/revision',
  git_path: './.git',
  revision: lambda { |git_path| `git log -1 --pretty="format:%H"` },
  body: lambda { |revision| revision },
  status: lambda { |revision| revision ? 200 : 404 },
  headers: lambda { |revision| { 'Content-Type' => 'text/plain' }
}

Contributing

  1. Fork it ( https://github.com/attracie/rack-git-revision/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request