Skip to content

radar/shalala

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shalala

Shalala is a Rails engine that exposes the current git commit SHA and branch name at /commit.

What it does

When you request GET /commit:

  • If GIT_COMMIT is set, it returns that value.
  • If GIT_BRANCH is set, it returns that value for the branch.
  • If GIT_COMMIT is not set and the Rails environment is development, it runs git rev-parse HEAD and returns the current SHA.
  • If GIT_BRANCH is not set, it derives the branch from git (git branch --show-current, with git rev-parse --abbrev-ref HEAD as fallback).
  • If GIT_COMMIT is not set and the environment is not development, it returns 404 Not Found.

This is useful for surfacing deployment version information in environments like staging and production.

Installation

Add this line to your application Gemfile:

gem "shalala"

Then install:

bundle install

Mounting

The engine mounts itself at /commit via an initializer, so no manual route declaration is required.

Usage examples

Set the commit explicitly (recommended for CI/CD and production):

export GIT_COMMIT=$(git rev-parse HEAD)
export GIT_BRANCH=$(git branch --show-current)

Then request:

curl http://localhost:3000/commit

Example response:

commit: f2e9b8d4a3c11f2f9c2fd6f5b76f6f3cf1a1d9e2
branch: main

Testing

Run the test suite with:

bundle exec rspec

License

MIT

About

Shalala is a Rails engine that exposes the current git commit SHA and branch name at `/commit`.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages