Rack::GitRevision

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

Customize Url

Change Url path

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

Change how to get revision

use Rack::GitRevision, { revision: lambda { File.read('./REVISION').strip } }

Options

Defaults

options = {
  path: '/dev/revision',
  revision: lambda { `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