Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can I run `git describe` in a heroku app's environment.rb?

I've got this chunk of code that pulls the git version of the current repo when the environment kicks on (environment.rb).

APP_VERSION = `git describe --always --long` unless defined? APP_VERSION

That let's me pull up the site, go to a certain page and see that the version that's on the site is the right one. This bit of code was working on EngineYard, but on Heroku I'm getting this when the app starts up:

fatal: Not a git repository (or any of the parent directories): .git

Is running git describe possible on heroku?

like image 334
jcollum Avatar asked Nov 19 '12 17:11

jcollum


1 Answers

I don't think you can; when you deploy your app to Heroku using git push, it appears to put it into a repository, then do a clean checkout of your code without a git repository. You can poke around using the heroku run bash command and see what's there. Here's what's there for one of my apps:

$ heroku run bash
Running `bash` attached to terminal... up, run.1
~ $ ls -a
.    bin      config.ru  Gemfile       lib         public    .rspec  TODO.txt
..   .bundle  db         Gemfile.lock  Procfile    Rakefile  script  vendor
app  config   doc        .gitignore    .profile.d  README    spec

No .git directory, so git commands won't work.

If you want to just see what version is currently deployed, you can see that from the Heroku Dashboard for your app, under the Activity tab. (https://dashboard.heroku.com/apps/[your app name]/activity) But I'm not sure how to get the git version into your application code so you can display it as part of your app.

like image 125
dpassage Avatar answered Sep 29 '22 14:09

dpassage