var buildFile = require('./build-file')
var runGitCommand = require('./helpers/run-git-command')

var commithashCommand = 'rev-parse HEAD'
var versionCommand = 'describe --always'

function GitRevisionPlugin (options) {
  this.gitWorkTree = options && options.gitWorkTree
  this.lightweightTags = options && options.lightweightTags || false
  this.commithashCommand = options && options.commithashCommand || commithashCommand
}

GitRevisionPlugin.prototype.apply = function (compiler) {
  buildFile(compiler, this.gitWorkTree, this.commithashCommand, /\[git-revision-hash\]/gi, 'COMMITHASH')
  buildFile(compiler, this.gitWorkTree, versionCommand + (this.lightweightTags ? ' --tags' : ''), /\[git-revision-version\]/gi, 'VERSION')
}

GitRevisionPlugin.prototype.commithash = function (callback) {
  return runGitCommand(this.gitWorkTree, this.commithashCommand)
}

GitRevisionPlugin.prototype.version = function (callback) {
  return runGitCommand(this.gitWorkTree, versionCommand + (this.lightweightTags ? ' --tags' : ''))
}

module.exports = GitRevisionPlugin

@@ -419,16 +419,92 @@
 Command%0A
+  this.versionCommand = options && options.versionCommand %7C%7C versionCommand%0A
 %7D%0A%0AGitRe
@@ -693,32 +693,37 @@
 is.gitWorkTree, 
+this.
 versionCommand +
@@ -1040,16 +1040,21 @@
 rkTree, 
+this.
 versionC

Allow custom version commands as well 👯