Skip to content

Commit

Permalink
use existing git-standup implementation
Browse files Browse the repository at this point in the history
because it just works ;-)
  • Loading branch information
mojoaxel committed May 7, 2017
1 parent 4cf5e21 commit 86caaa0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 20 deletions.
43 changes: 23 additions & 20 deletions care.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,49 +117,52 @@ function doTheCodes() {
var todayCommits = 0;
var weekCommits = 0;

function getCommits(box, data) {
function getCommits(data, box) {
var content = colorizeLog(data || '');
box.content += content;
var commitRegex = /(.......) (- .*)/g;
return (box && box.content) ? (box.content.match(commitRegex) || []).length : '0';
}

if (config.gitbot.toLowerCase() === 'gitstandup') {
var today = spawn('sh ' + __dirname + '/standup-helper.sh', ['-m ' + config.depth, config.repos], {shell:true});
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();
});
today.stdout.on('data', data => {
todayCommits = getCommits(`${data}`, todayBox);
updateCommitsGraph(todayCommits, weekCommits);
screen.render();
});

var week = spawn('sh ' + __dirname + '/standup-helper.sh', ['-m ' + config.depth + ' -d 7', config.repos], {shell:true});
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();
});
week.stdout.on('data', data => {
weekCommits = getCommits(`${data}`, weekBox);
updateCommitsGraph(todayCommits, weekCommits);
screen.render();
});
} else {
gitbot.findGitRepos(config.repos, config.depth-1, (err, allRepos) => {
if (err)
if (err) {
return todayBox.content = err;
screen.render();
}
gitbot.getCommitsFromRepos(allRepos, 1, (err, data) => {
if (err)
if (err) {
return todayBox.content = err;
screen.render();
}
todayBox.content = '';
todayCommits = getCommits(todayBox, `${data}`);
todayCommits = getCommits(`${data}`, todayBox);
updateCommitsGraph(todayCommits, weekCommits);
screen.render();
});
gitbot.getCommitsFromRepos(allRepos, 7, (err, data) => {
if (err)
if (err) {
return weekBox.content = err;
screen.render();
}
weekBox.content = '';
weekCommits = getCommits(weekBox, `${data}`);
weekCommits = getCommits(`${data}`, weekBox);
updateCommitsGraph(todayCommits, weekCommits);
screen.render();
});
Expand Down
36 changes: 36 additions & 0 deletions standup-helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -e

# I couldn't figure out how to cd into a different working directory
# and run git-standup there directly from node (cwd did nothing), so
# here we are.

progname=$0
standup=$(npm bin -g)"/git-standup"

usage () {
echo "Usage: "
echo " $progname [-d days] [-h] repo1 repo2 etc."
echo " -d \t - Specify the number of days back to include"
echo " -m \t - Specify the depth of recursive repository search"
echo " -h \t - Display this help screen"
}

# get the optional days
days=1
depth=1
while getopts "d:m:h" opt; do
case $opt in
d ) days=$OPTARG;;
m ) depth=$OPTARG;;
h ) usage ;;
\?) usage ;;
esac
done
shift $(($OPTIND - 1))

# the repo names
for dir in "$@"
do
(cd $dir; $standup -d $days -m $depth)
done

0 comments on commit 86caaa0

Please sign in to comment.