function getCommitMessage(file, hash, callback) { const repoPath = findRepo(file) if (!repoPath) { return; } const git = new Git({ 'git-dir': repoPath }) git.exec('show', showOpts, [ hash ], (error, msg) => { if (error) { return } callback(msg) }) }
module.exports = function(options, callback) { var gitOptions = { format: 'tar', remote: options.source, output: options.tarfile || path.join(options.tmpDir || '/tmp', uuid.v4()+'.tar'), prefix: options.prefix || '' }; // Remove tarfile if savetar option is false, otherwise // return path to tarfile function cleanup() { if (!options.savetar) { fs.unlinkSync(gitOptions.output); return; } return gitOptions.output; } // Download git repository as a tar file git.exec('archive', gitOptions, [options.branch], function (err, msg) { if (err) { // Error occurred downloading from the source callback && callback(err); return; } if (options.dest) { // Read in the downloaded tarfile fs.createReadStream(gitOptions.output) // Explode the downloaded tarfile .pipe(tar.Extract({ path: options.dest })) // Handle extraction errors .on('error', function (er) { callback && callback(er); }) // Handle successful extraction completion .on('end', function () { // Return string containing path to downloaded tarfile. callback && callback(null, cleanup()); }); } else { // Return string containing path to downloaded tarfile. callback && callback(null, cleanup()); } }); };
grunt.registerMultiTask('exec', function () { var options = this.options({ full: false }); var done = this.async(); var run = function (target) { var args = []; args.push(path.resolve(__dirname, 'dist', 'index.js')); if (options.tests) { args.push('--tests'); } if (options.lint) { args.push('--lint'); } if (options.changes) { args.push('--changes'); } if (options.debug) { args.push('--debug'); } args.push('--path', target); var opts = { cwd: target, stdio: 'inherit' }; childProcess.spawn('node', args, opts).on('close', function (code) { console.log('child process exited with code ' + code); done((code === 0)); }); }; if (options.full) { var fs = require('fs'); fs.mkdirSync('tmp'); var Git = require('git-wrapper'); var git = new Git({ 'git-dir': 'tmp/.git' }); var opts = { depth: 20 }; var args = [ 'https://github.com/borisyankov/DefinitelyTyped', 'tmp' ]; console.log('cloning repos..'); git.exec('clone', opts, args, function (err, msg) { console.log(msg); if (err) { done(err); } else { run(path.resolve(__dirname, 'tmp')); } }); } else { run(path.resolve(__dirname, '..', 'DefinitelyTyped-dojo')); } });