grunt-githash
Grunt plugin to get the current git hash, git branch and git tag
Getting Started
This plugin requires Grunt.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-githash --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt;
The "githash" task
Overview
In your project's Gruntfile, add a section named githash
to the data object passed into grunt.initConfig()
.
grunt
Options
options.dir
Type: String
Default value: '.'
options.fail
Type: Boolean
Default value: true
Reports a warning if not inside a git respository
Available values
githash.{target}.branch
Type: String
Value: branch name
githash.{target}.tag
Type: String
Value: tag name
githash.{target}.hash
Type: String
Value: the full hash value
githash.{target}.short
Type: String
Value: the short git hash value
Usage Examples
Default Options
In this example, the default options are used to get the git status.
grunt
Custom Options
In this example, we define the git repository location
grunt
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
License
Copyright (c) 2015 Jan Nicklas. Licensed under the MIT license.