Created
September 16, 2014 00:14
-
-
Save klamping/95ed8a7310b854391d62 to your computer and use it in GitHub Desktop.
List all open PRs for repos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// Run with `node prs.js` | |
// or chmod the file and run via `./prs.js` | |
/*jshint node:true*/ | |
var https = require('https'); | |
var util = require('util'); | |
var options = { | |
host: 'api.github.com', | |
headers: { | |
'User-Agent': 'pr-reviewer' | |
} | |
}; | |
// Encore UI Pull Request Overview | |
var owner = 'rackerlabs'; | |
var repos = [ | |
'encore-ui', | |
'encore-ui-template', | |
'encore-ui-nav', | |
'encore-ui-login' | |
]; | |
var printPR = function (pr) { | |
console.log('\n' + pr['title']); | |
console.log(pr['html_url']); | |
console.log(pr['body']); | |
}; | |
var printPRs = function (prs) { | |
if (prs.length > 0) { | |
console.log('#### PRs for ' + prs[0].head.repo.name + ' ####'); | |
for (var i = 0; i < prs.length; i++) { | |
printPR(prs[i]); | |
} | |
console.log('\n--------\n'); | |
} | |
}; | |
var handleResponse = function (response) { | |
var str = ''; | |
//another chunk of data has been recieved, so append it to `str` | |
response.on('data', function (chunk) { | |
str += chunk; | |
}); | |
//the whole response has been recieved, so we just print it out here | |
response.on('end', function () { | |
printPRs(JSON.parse(str)); | |
}); | |
}; | |
// clear the screen | |
util.print("\u001b[2J\u001b[0;0H"); | |
for (var i = 0; i < repos.length; i++) { | |
// build URL with | |
options.path = util.format('/repos/%s/%s/pulls', owner, repos[i]); | |
// make request | |
https.request(options, handleResponse).end(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment