/*
 * grunt-git-describe
 * https://github.com/ika18/grunt-git-rev-parse
 *
 * Copyright (c) 2013 Ika Wu
 * Licensed under the Apache 2 license.
 */


 "use strict";

module.exports = function (grunt) {
    var CWD = "cwd";
    var PROP = "prop";
    var NUM = "number";
    var REV = "rev";

    grunt.registerMultiTask("git-rev-parse", "Get git revision id", function (prop, cwd) {
        // Start async task
        var done = this.async();

        // Define default options
        var options = {};
        options[CWD] = ".";
        options[NUM] = 6;
        options[REV] = "HEAD";
    
        // Load cli options (with defaults)
        options = this.options(options);

        // Override options
        options[PROP] = prop || options[PROP];
        options[CWD] = cwd || options[CWD];
        options[NUM] = grunt.option(NUM) || options[NUM];
        options[REV] = grunt.option(REV) || options[REV];

        // Log flags (if verbose)
        grunt.log.verbose.writeflags(options);

        // Spawn git
        grunt.util.spawn({
            "cmd" : "git",
            "args" : [ "rev-parse", "--verify", "--short=" +  options[NUM], options[REV]],
            "opts" : {
                "cwd" : options[CWD]
            }
        }, function (err, result) {
            // If an error occurred...
            if (err) {
                // Log the problem and let grunt continue
                grunt.log.error(err,result);
                done();
                return;
            }

            // Convert result to string
            result = String(result);

            // Output
            grunt.log.ok(result);

            // If we were passed a prop we should update
            if (options[PROP]) {
                grunt.config(options[PROP], result);
            }
            
            // Done with result
            done();
        });
    });
};
@@ -285,17 +285,48 @@
  %22rev%22;%0A
+    var SILENT = %22silent%22;%0A    
 %0A
-
     grun
@@ -615,16 +615,49 @@
 %22HEAD%22;%0A
+        options%5BSILENT%5D = false;%0A
     %0A   
@@ -973,16 +973,83 @@
 ns%5BREV%5D;
+%0A        options%5BSILENT%5D = grunt.option(SILENT) %7C%7C options%5BSILENT%5D;
 %0A%0A      
@@ -1728,16 +1728,77 @@
  Output%0A
+            if (!options%5BSILENT%5D %7C%7C grunt.log.verbose) %7B%0A    
         
@@ -1814,32 +1814,46 @@
 .log.ok(result);
+%0A            %7D
 %0A%0A            //
@@ -2080,10 +2080,11 @@
     %7D);%0A
-
 %7D;
+%0A

Update git-rev-parse.js