Tiny rack application that serves up the currently deployed git commit SHA.
Inspired by https://github.com/site/sha
Add this line to your application's Gemfile:
gem 'rack-git_sha'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rack-git_sha
If your using rails 3.0+ you can mount the app in your routes.rb
file.
MyApp::Application.routes.draw do
mount Rack::GitSha => '/sha'
end
If your using rack then you can map the middleware in your config.ru
.
require 'rack/git_sha'
map '/sha' do
run Rack::GitSha
end
map '/' do
run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['Homepage']] }
end
The argument that is given to #new
is the path to the current project,
it will default to Dir.pwd
if none is given.
After restarting your app, visiting /sha
should give you the current
git revision.
Once you've got your application serving the current SHA you can do some fun stuff from the command line.
cd example-app
curl -s http://app.example.com/sha
git diff $(curl -fsSL http://app.example.com/sha)
This will do a diff against the deployed sha, showing you what is still
pending (much like capistrano's cap deploy:pending:diff
).
- Does not work with Heroku.
This gem provides a capistrano task to ensure your app has the required
REVISION
file for Rack::GitSha to work.
To enable the capistrano task add the following line to your Capfile
require 'capistrano/revision'
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request