Skip to content

Commit

Permalink
make it possible to switch between git-standup and gitlog
Browse files Browse the repository at this point in the history
  • Loading branch information
mojoaxel committed Apr 27, 2017
1 parent 1aed41b commit 3f3886d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 17 deletions.
56 changes: 39 additions & 17 deletions care.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var config = require(__dirname + '/config.js');
var twitterbot = require(__dirname + '/twitterbot.js');
var gitbot = require(__dirname + '/gitbot.js');

var spawn = require('child_process').spawn;
var blessed = require('blessed');
var contrib = require('blessed-contrib');
var chalk = require('chalk');
Expand Down Expand Up @@ -123,26 +124,47 @@ function doTheCodes() {
return (box && box.content) ? (box.content.match(commitRegex) || []).length : '0';
}

gitbot.findGitRepos(config.repos, config.depth-1, (err, allRepos) => {
if (err)
return showError(err);
gitbot.getCommitsFromRepos(allRepos, 1, (err, data) => {
if (err)
return todayBox.content = err;
todayBox.content = '';
todayCommits = getCommits(todayBox, `${data}`);
updateCommitsGraph(todayCommits, weekCommits);
screen.render();
if (config.gitbot.toLowerCase() === 'gitstandup') {
todayBox.content = '';
config.repos.forEach(repo => {
var today = spawn(`cd ${repo} && git-standup`, [`-m ${config.depth}`, '-d 1'], {shell:true});
today.stdout.on('data', data => {
todayCommits = getCommits(todayBox, `${data}`);
updateCommitsGraph(todayCommits, weekCommits);
screen.render();
});
});
weekBox.content = '';
config.repos.forEach(repo => {
var today = spawn(`cd ${repo} && git-standup`, [`-m ${config.depth}`, '-d 7'], {shell:true});
today.stdout.on('data', data => {
weekCommits = getCommits(weekBox, `${data}`);
updateCommitsGraph(todayCommits, weekCommits);
screen.render();
});
});
gitbot.getCommitsFromRepos(allRepos, 7, (err, data) => {
} else {
gitbot.findGitRepos(config.repos, config.depth-1, (err, allRepos) => {
if (err)
return weekBox.content = err;
weekBox.content = '';
weekCommits = getCommits(weekBox, `${data}`);
updateCommitsGraph(todayCommits, weekCommits);
screen.render();
return todayBox.content = err;
gitbot.getCommitsFromRepos(allRepos, 1, (err, data) => {
if (err)
return todayBox.content = err;
todayBox.content = '';
todayCommits = getCommits(todayBox, `${data}`);
updateCommitsGraph(todayCommits, weekCommits);
screen.render();
});
gitbot.getCommitsFromRepos(allRepos, 7, (err, data) => {
if (err)
return weekBox.content = err;
weekBox.content = '';
weekCommits = getCommits(weekBox, `${data}`);
updateCommitsGraph(todayCommits, weekCommits);
screen.render();
});
});
});
}
}

function makeBox(label) {
Expand Down
3 changes: 3 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ var config = {
// Directory-depth to look for git repositories.
depth: (process.env.TTC_REPOS_DEPTH || 1),

// Which method is to be used to read the git commits ('gitstandup' | 'gitlog').
gitbot: (process.env.TTC_GITBOT || 'gitstandup'),

// Where to check the weather for.
// It's using weather.service.msn.com behind the curtains.
weather: process.env.TTC_WEATHER || 'San Francisco',
Expand Down

0 comments on commit 3f3886d

Please sign in to comment.