Code Monkey home page Code Monkey logo

git-revision's Introduction

Git Revision

Git Revision is a simple (45 SLoC) Ruby gem that provides basic information about git source code. You can use it in your apps, for example, to show deployed version.

Installation

Add to Gemfile:

gem 'git-revision'

and run:

bundle install

Usage

Git::Revision.info will return the following hash:

{
  :author => "John Smith",
  :branch => "master",
  :commit_hash => "60619c10baca6f9b4d03253697d43b7cf5d08edf",
  :commit_hash_short => "60619c1",
  :commit_subject => "release beta version",
  :authored_date => "Fri Jun 8 17:55:01 2012 +0500",
  :authored_timestamp => "1339160101",
  :commit_tag => "4.2.0.beta",
  :repo_last_tag => "4.2.0.beta"
}

Additionally you can access these methods directly:

Git::Revision.author       # returns last commit author
Git::Revision.branch       # returns current branch
Git::Revision.commit       # returns last commit hash
Git::Revision.commit_short # returns abbreviated last commit hash (7 characters)
Git::Revision.message      # returns last commit message subject
Git::Revision.date         # returns authored date of last commit
Git::Revision.timestamp    # returns authored date of last commit in Unix time
Git::Revision.tag          # returns last commit tag if exists
Git::Revision.last_tag     # returns last tag in repository if exists

License

Released under the BSD 2-clause license. See LICENSE.txt for details.

git-revision's People

Contributors

givp avatar jdashton avatar lain0 avatar narkoz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

git-revision's Issues

Branch Information

Hi, it would be great if branch information is also available.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.