Get current Git commit version in Rails app
If you need to get your Git version, do the following:
commit = `git rev-parse HEAD`
puts commit #=> 0cfc01d47d1753bb1e55fb347644239b70ab2772
#short version
commit = `git rev-parse --short HEAD`
puts commit #=> 0cfc01d
If you need to get a Fit version from Github repository, you can use gem "github_api"
https://github.com/peter-murach/github
github = Github.new auth_token
commits = github.repos.commits.all 'username', 'project'
commits.first['sha']
Written by David Paluy
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#