lsvxxg
Last Updated: February 25, 2016
·
640
· dpaluy
3129de6b479cc965513311f1ddcc268a

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']
Say Thanks
Respond
Awesome Job

B6c77ad0 c95b 11e7 8263 8f89080b8db6
Ruby Developer Backend
·
Austria (Vienna or Linz)
·
Full Time