Skip to content

Instantly share code, notes, and snippets.

@areichman
Created August 30, 2016 16:23
Show Gist options
  • Save areichman/7ea44e8e1819f2ab31ee6eeb44cea319 to your computer and use it in GitHub Desktop.
Save areichman/7ea44e8e1819f2ab31ee6eeb44cea319 to your computer and use it in GitHub Desktop.
Grunt task to get a repo's short Git hash
'use strict';
module.exports = function(grunt) {
grunt.task.registerTask('githash', function() {
var done = this.async();
grunt.util.spawn({
cmd: 'git',
args: ['rev-parse', '--short', 'HEAD']
}, function(err, result, code) {
if (err) {
grunt.log.error(err);
done(false);
} else {
grunt.config('githash', result);
grunt.log.writeln('At revision ' + result);
done(true);
}
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment