Comparing version 1.1.5 to 1.2.0
{ | ||
"name": "rbwhat", | ||
"version": "1.1.5", | ||
"version": "1.2.0", | ||
"description": "Quickly list review-board requests that need your attention", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
#!/usr/bin/env node | ||
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
var allowedAge, client, colorName, config, configPath, deprecateKey, extend, formatDate, formatHeading, fs, loadExistingConfig, loadOptions, main, moment, needsReview, pad, printActiveRequest, querystringify, rbapi, rbapiReviewRequests, rbapiReviews, syncConfig, tooOld, user; | ||
var allowedAge, byAge, client, colorName, config, configPath, deprecateKey, extend, formatDate, formatHeading, fs, loadExistingConfig, loadOptions, main, moment, needsReview, outputReviewActivity, pad, printActiveRequest, querystringify, rbapi, rbapiDiffs, rbapiReviewRequests, rbapiReviews, syncConfig, tooOld, user; | ||
@@ -44,19 +44,29 @@ require('colors'); | ||
submitter = request.links.submitter.title; | ||
return rbapiReviews(request.id, function(reviews) { | ||
var date, output, review, reviewer, show, _i, _len; | ||
show = user !== submitter && !tooOld(request.time_added); | ||
output = formatHeading(submitter, request); | ||
for (_i = 0, _len = reviews.length; _i < _len; _i++) { | ||
review = reviews[_i]; | ||
date = review.timestamp; | ||
reviewer = review.links.user.title; | ||
show = needsReview(reviewer, submitter, show, date); | ||
output.push(' ' + pad(colorName(reviewer, submitter, review.ship_it), 22) + formatDate(date)); | ||
} | ||
if (show) { | ||
return console.log(output.join('\n')); | ||
} | ||
return rbapiDiffs(request.id, submitter, function(diffs) { | ||
return rbapiReviews(request.id, function(reviews) { | ||
return outputReviewActivity(submitter, request, reviews.concat(diffs).sort(byAge)); | ||
}); | ||
}); | ||
}; | ||
byAge = function(a, b) { | ||
return new Date(a.timestamp) - new Date(b.timestamp); | ||
}; | ||
outputReviewActivity = function(submitter, request, reviews) { | ||
var date, output, review, reviewer, show, _i, _len; | ||
output = formatHeading(submitter, request); | ||
show = user !== submitter; | ||
for (_i = 0, _len = reviews.length; _i < _len; _i++) { | ||
review = reviews[_i]; | ||
date = review.timestamp; | ||
reviewer = review.links.user.title; | ||
show = needsReview(reviewer, submitter, show, date); | ||
output.push(' ' + pad(colorName(reviewer, submitter, review.ship_it), 22) + formatDate(date)); | ||
} | ||
if (show) { | ||
return console.log(output.join('\n')); | ||
} | ||
}; | ||
needsReview = function(reviewer, submitter, show, date) { | ||
@@ -89,3 +99,3 @@ if (user === reviewer) { | ||
} | ||
return ["" + (pad(colorName(submitter, submitter), 25)) + " " + title, "" + repo + " " + bug + " " + branch, " " + url + " " + (formatDate(request.time_added))]; | ||
return ["" + (pad(colorName(submitter, submitter), 25)) + " " + title, "" + repo + " " + bug + " " + branch, " " + url]; | ||
}; | ||
@@ -124,8 +134,9 @@ | ||
rbapi = function(path, args, cb) { | ||
var query; | ||
var query, url; | ||
query = '?' + querystringify(args); | ||
url = config.url + path + query; | ||
if (config.debug) { | ||
console.log("curl '" + (config.url + path + query) + "' | jsonpp"); | ||
console.log("curl '" + url + "' | jsonpp | vim -c 'setf javascript' -"); | ||
} | ||
return client.get(config.url + path + query, function(res) { | ||
return client.get(url, function(res) { | ||
return cb(JSON.parse(res)); | ||
@@ -147,2 +158,18 @@ }); | ||
rbapiDiffs = function(id, submitter, cb) { | ||
return rbapi("api/review-requests/" + id + "/diffs/", null, function(res) { | ||
return cb(res.diffs.map(function(diff) { | ||
return { | ||
ship_it: false, | ||
timestamp: diff.timestamp, | ||
links: { | ||
user: { | ||
title: submitter | ||
} | ||
} | ||
}; | ||
})); | ||
}); | ||
}; | ||
syncConfig = function() { | ||
@@ -149,0 +176,0 @@ if (fs.existsSync(configPath)) { |
Sorry, the diff of this file is not supported yet
69517
178