Can I run `git describe` in the heroku environment.rb application?

I have this piece of code that pulls out the git version of the current repo when the environment starts (environment.rb).

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

This allowed me to pull up the site, go to a specific page and see that the version that is on the site is correct. This bit of code worked on EngineYard, but on Heroku I get this when the application starts:

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

Is it possible to run git describe on a hero?

+4
source share
1 answer

I do not think you can; when you deploy your application to Heroku using git push , it seems to put it in the repository and then do a clean code check without the git repository. You can pop with the heroku run bash command and see what is there. Here is what is there for one of my applications:

 $ 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 , so git commands will not work.

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

+5
source

Source: https://habr.com/ru/post/1447032/


All Articles