Skip to content

Commit

Permalink
add git show-branch command (#197)
Browse files Browse the repository at this point in the history
* add git show-branch command

* add doc

* cleanup log (remove quiet mode)
  • Loading branch information
fpassaniti authored and stephenlacy committed Dec 4, 2019
1 parent cb98cb8 commit 346ea2a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,21 @@ git.branch('development', function (err) {
});
```

### git.showBranch(opt, cb)
`git show-branch <opt>`

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 <new branch name>`

Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
23 changes: 23 additions & 0 deletions lib/showBranch.js
Original file line number Diff line number Diff line change
@@ -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);
});
};

0 comments on commit 346ea2a

Please sign in to comment.