Skip to content

Commit

Permalink
Merge branch 'gitlog' of github.com:mojoaxel/tiny-care-terminal into …
Browse files Browse the repository at this point in the history
…gitlog
  • Loading branch information
mojoaxel committed May 12, 2017
2 parents f945c1e + 7d6ed23 commit e1ded0d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 21 deletions.
43 changes: 23 additions & 20 deletions care.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,49 +171,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
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@
"blessed": "^0.1.81",
"blessed-contrib": "^4.7.5",
"chalk": "^1.1.3",
"git-standup": "^2.1.8",
"git-user-name": "^1.2.0",
"gitlog": "^2.4.0",
"is-git": "0.0.1",
"node-notifier": "^5.1.2",
"parrotsay-api": "^0.1.1",
"resolve-dir": "^1.0.0",
"sign-bunny": "^1.0.0",
"scraperjs": "^1.2.0",
"sign-bunny": "^1.0.0",
"subdirs": "^1.0.1",
"twit": "^2.2.5",
"weather-js": "^2.0.0"
},
"peerDependencies": {
"git-standup": "^2.1.8"
},
"scripts": {
"start": "node care.js"
}
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 e1ded0d

Please sign in to comment.