views:

78

answers:

2

I've got a couple of different branches of a rails app running in a development environment on the same server (on separate databases, obv), and I'd like to make it very clear what branch is being shown when I hit the app through the web.

Any ideas, short of running git-branch or git-symbolic-ref HEAD in backticks and parsing the output?

A: 

Actually, as you suggested, shelling out is the right thing to do.

If you're afraid somehow git might not be available to the app, you might try reading the file .git/HEAD.

kch
+3  A: 

Check out Grit, it allows you to read a Git repository using Ruby.

repository = Grit::Repo.new(RAILS_ROOT)
repository.head.name # => "master"
ryanb