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.('../../repo/.git', __FILE__) : nil
}
run Rails.application
Options
Defaults
= {
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
- Fork it ( https://github.com/attracie/rack-git-revision/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request