Project

git_rev

0.0
No commit activity in last 3 years
No release in over 3 years
Get the git revision of a given repository. Does not require Git binaries
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
>= 2.11.1, ~> 2.11
>= 2.3.2, ~> 2.3
>= 5.4.1, ~> 5.4
~> 10.0
>= 0.5.0, ~> 0.5
 Project Readme

GitRev

Retrieve the SHA-1 hash of the current revision of a Git repository. GitRev uses the contents of the .git directory therefore it does not require Git to be installed.

Installation

Add this line to your application's Gemfile:

gem 'git_rev'

And then execute:

$ bundle

Or install it yourself as:

$ gem install git_rev

Usage

SHA-1

By default, GitRev::Sha uses the current directory as the Git repository and caches the revision number:

require 'git_rev'

revision = GitRev::Sha.new

revision.full
#=> 1f7995f701d02f2f62b2e7faa91a1e16f3d68666

revision.short
#=> 1f7995f

You may specify the location of the Git repository:

revision = GitRev::Sha.new(repository: '/path/to/repository')

By default, the cache is enabled, meaning GitRev will only query the filesystem once. If you need to ensure the revision info is reloaded each time:

revision = GitRev::Sha.new(repository: '/path/to/repository', cache: false)

revision.short
#=> 1f7995f

`git commit -m "A message"`

revision.short
# => 658f674

Contributing

  1. Fork it ( https://github.com/[my-github-username]/git_rev/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request