-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathupstream.js
59 lines (50 loc) · 1.4 KB
/
upstream.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var _ = require('lodash');
var async = require('async');
var fs = require('fs');
var http = require('http');
var watch = require('watch');
var sass = require("node-sass");
var path = require('path');
var green = '\u001b[42m \u001b[0m';
var red = '\u001b[41m \u001b[0m';
var exec = require('child_process').exec;
var utils;
module.exports = {
name:'upstream',
description:'Runs a git fetch and tells you what has changed upstream for all your repos',
example:'bosco upstream',
cmd:cmd
}
function cmd(bosco, args) {
var repos = bosco.config.get('github:repos');
if(!repos) return bosco.error("You are repo-less :( You need to initialise bosco first, try 'bosco fly'.");
var changedRepos = function(cb) {
async.mapSeries(repos, function repoStash(repo, repoCb) {
var repoPath = bosco.getRepoPath(repo);
upstream(bosco, repoPath, repoCb);
}, function(err) {
cb();
});
}
bosco.log("Checking upstream origin for changes, this may take a while ...")
changedRepos(function() {
bosco.log("Complete");
});
}
function upstream(bosco, orgPath, next) {
exec('git fetch; git log HEAD..origin/master --oneline', {
cwd: orgPath
}, function(err, stdout, stderr) {
if(err) {
bosco.error(stderr);
} else {
if(stdout) {
bosco.log("Changes in " + orgPath.blue);
console.log(stdout);
} else {
bosco.log(orgPath.blue + ": " + "No Change".green);
}
}
next(err);
});
}