diff --git a/README.md b/README.md index 009313e..584f07e 100644 --- a/README.md +++ b/README.md @@ -539,6 +539,21 @@ git.branch('development', function (err) { }); ``` +### git.showBranch(opt, cb) +`git show-branch ` + +Show branches and their commits + +`opt`: Object (optional) `{args: 'options'}` + +`cb`: function, passed err if any + +```js +git.showBranch({'args': '--list -a'}, function (err) { + //if (err) ... +}); +``` + ### git.checkout(branch, opt, cb) `git checkout ` diff --git a/index.js b/index.js index b48e40e..8eb57d1 100644 --- a/index.js +++ b/index.js @@ -23,6 +23,7 @@ * @property {function} reset {@link module:gulp-git/lib/reset} * @property {function} revParse {@link module:gulp-git/lib/revParse} * @property {function} rm {@link module:gulp-git/lib/rm} + * @property {function} showBranch {@link module:gulp-git/lib/showBranch} * @property {function} stash {@link module:gulp-git/lib/stash} * @property {function} status {@link module:gulp-git/lib/status} * @property {function} tag {@link module:gulp-git/lib/tag} diff --git a/lib/showBranch.js b/lib/showBranch.js new file mode 100644 index 0000000..0584cc2 --- /dev/null +++ b/lib/showBranch.js @@ -0,0 +1,23 @@ +'use strict'; + +var log = require('fancy-log'); +var exec = require('child_process').exec; + +module.exports = function (opt, cb) { + if (!cb && typeof opt === 'function') { + // optional options + cb = opt; + opt = {}; + } + if (!cb || typeof cb !== 'function') cb = function () {}; + if (!opt) opt = {}; + if (!opt.cwd) opt.cwd = process.cwd(); + if (!opt.args) opt.args = ' '; + + var cmd = 'git show-branch ' + opt.args; + return exec(cmd, {cwd: opt.cwd}, function(err, stdout, stderr) { + if (err) return cb(err); + log(stdout, stderr); + cb(null, stdout); + }); +};