0.0
No commit activity in last 3 years
No release in over 3 years
Serve up the current git commit SHA from rack
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.6.1
~> 0.9.2
~> 2.8.0
 Project Readme

Rack::GitSha CI

Tiny rack application that serves up the currently deployed git commit SHA.

Inspired by https://github.com/site/sha

Installation

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

Usage

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.

Tips

Once you've got your application serving the current SHA you can do some fun stuff from the command line.

Currently deployed SHA

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).

Known issues

  • Does not work with Heroku.

Capistrano 3 support

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'

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request