git-apply-pr
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -30,3 +30,2 @@ #!/usr/bin/env node | ||
var fs = require('fs'); | ||
var https = require('https'); | ||
var os = require('os'); | ||
@@ -40,2 +39,3 @@ var path = require('path'); | ||
var lstream = require('lstream'); | ||
var request = require('request'); | ||
@@ -46,9 +46,22 @@ if (!process.argv[2]) { | ||
var args = /(.*)\/(.*)#(\d*)/i.exec(process.argv[2]); | ||
if (!args) { | ||
var ENABLE_PLUS_ONE = false; | ||
var ownerRepoPrArg; | ||
process.argv.slice(2).forEach(function(arg) { | ||
if (!/^\-\-/.test(arg)) { | ||
ownerRepoPrArg = arg; | ||
return; | ||
} | ||
if (/^\-\-plusone/.test(arg)) { | ||
ENABLE_PLUS_ONE = true; | ||
return; | ||
} | ||
}); | ||
var ownerRepoPr = /(.*)\/(.*)#(\d*)/i.exec(ownerRepoPrArg); | ||
if (!ownerRepoPr) { | ||
exitWithMsg('Usage example: git-apply-pr joyent/node#1337'); | ||
} | ||
var OWNER = args[1]; | ||
var REPO = args[2]; | ||
var PR = +args[3]; | ||
var OWNER = ownerRepoPr[1]; | ||
var REPO = ownerRepoPr[2]; | ||
var PR = +ownerRepoPr[3]; | ||
var HOST = 'github.com'; | ||
@@ -91,3 +104,3 @@ | ||
'PR': util.format('#%d', PR), | ||
'PR-URL': util.format('/%s/%s/pull/%d', OWNER, REPO, PR), | ||
'PR-URL': util.format('https://%s/%s/%s/pull/%d', HOST, OWNER, REPO, PR), | ||
'Reviewed-By': {}, | ||
@@ -112,3 +125,3 @@ }; | ||
comments.forEach(function (comment) { | ||
if (/lgtm/i.test(comment.body)) { | ||
if (/lgtm/i.test(comment.body) || maybeTestForPlusone(comment.body)) { | ||
var val = reviews[comment.user.login] || 0; | ||
@@ -126,2 +139,10 @@ reviews[comment.user.login] = val + 1; | ||
function maybeTestForPlusone(comment) { | ||
if (!ENABLE_PLUS_ONE) { | ||
return false; | ||
} | ||
return /\+1/.test(comment); | ||
} | ||
function resolveNames() { | ||
@@ -153,9 +174,8 @@ var queue = Object.keys(OUTPUT['Reviewed-By']); | ||
function applyPatch() { | ||
var req = https.request({ | ||
hostname: HOST, | ||
path: OUTPUT['PR-URL'] + '.patch', | ||
}, function patchResponse(res) { | ||
res.pipe(new lstream()).pipe(new Mutator()).pipe(process.stdout); | ||
}); | ||
req.end(); | ||
request({ | ||
uri: OUTPUT['PR-URL'] + '.patch', | ||
followAllRedirects: true | ||
}) | ||
.pipe(new lstream()).pipe(new Mutator()).pipe(process.stdout); | ||
} | ||
@@ -196,3 +216,3 @@ | ||
this.m_message.push(util.format('PR: %s', OUTPUT['PR'])); | ||
this.m_message.push(util.format('PR-URL: https://%s%s', HOST, OUTPUT['PR-URL'])); | ||
this.m_message.push(util.format('PR-URL: %s', OUTPUT['PR-URL'])); | ||
@@ -199,0 +219,0 @@ var self = this; |
{ | ||
"name": "git-apply-pr", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Apply GitHub Pull Requests", | ||
@@ -8,5 +8,5 @@ "main": "apply-pr.js", | ||
"github": "~0.2.3", | ||
"lstream": "~0.0.4" | ||
"lstream": "~0.0.4", | ||
"request": "~2.55.0" | ||
}, | ||
"devDependencies": {}, | ||
"scripts": { | ||
@@ -13,0 +13,0 @@ "test": "echo \"Error: no test specified\" && exit 1" |
@@ -9,3 +9,9 @@ # git-apply-pr | ||
``` | ||
git-apply-pr joyent/node#1337 | ||
git-apply-pr joyent/git-apply-pr#4 | ||
``` | ||
To include support for using `+1` as a valid vote in favor of merging a pull | ||
request, you can use the `--plusone` command line switch like following: | ||
``` | ||
git-apply-pr --plusone apache/couchdb-fauxton#321 | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
8096
200
17
3
+ Addedrequest@~2.55.0
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedasn1@0.1.11(transitive)
+ Addedassert-plus@0.1.5(transitive)
+ Addedasync@0.9.2(transitive)
+ Addedaws-sign2@0.5.0(transitive)
+ Addedbl@0.9.5(transitive)
+ Addedbluebird@2.11.0(transitive)
+ Addedboom@2.10.1(transitive)
+ Addedcaseless@0.9.0(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcombined-stream@0.0.7(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedcryptiles@2.0.5(transitive)
+ Addedctype@0.5.3(transitive)
+ Addeddelayed-stream@0.0.5(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@0.2.0(transitive)
+ Addedgenerate-function@2.3.1(transitive)
+ Addedgenerate-object-property@1.2.0(transitive)
+ Addedhar-validator@1.8.0(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhawk@2.3.1(transitive)
+ Addedhoek@2.16.3(transitive)
+ Addedhttp-signature@0.10.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-my-ip-valid@1.0.1(transitive)
+ Addedis-my-json-valid@2.20.6(transitive)
+ Addedis-property@1.0.2(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsonpointer@5.0.1(transitive)
+ Addedmime-db@1.12.0(transitive)
+ Addedmime-types@2.0.14(transitive)
+ Addednode-uuid@1.4.8(transitive)
+ Addedoauth-sign@0.6.0(transitive)
+ Addedqs@2.4.2(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedrequest@2.55.0(transitive)
+ Addedsntp@1.0.9(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedstringstream@0.0.6(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedtldts@6.1.68(transitive)
+ Addedtldts-core@6.1.68(transitive)
+ Addedtough-cookie@5.0.0(transitive)
+ Addedtunnel-agent@0.4.3(transitive)
+ Addedxtend@4.0.2(transitive)