Skip to content

Commit

Permalink
No issue: Add helper programs to apply and land patches from GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
valueof committed Aug 3, 2013
1 parent 9c2b8dd commit a0b7181
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bin/apply
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node

var shjs = require("shelljs");
var url = "https://github.com/jshint/jshint/pull/" + process.argv[2] + ".diff";

shjs.exec('curl "' + url + '" | git apply');
37 changes: 37 additions & 0 deletions bin/land
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env node

var url = "https://github.com/jshint/jshint/pull/" + process.argv[2] + ".patch";
var https = require("https");
var shjs = require("shelljs");
var opts = require("url").parse(url);
var msg = process.argv[3];

opts.rejectUnauthorized = false;
opts.agent = new https.Agent(opts);

https.get(opts, succ).on("error", err);

function succ(res) {
if (res.statusCode !== 200)
return void console.log("error:", res.statusCode);

var data = "";
res.on("data", function (chunk) {
data += chunk.toString();
});

res.on("end", function () {
data = data.split("\n");
data = data[1].replace(/^From\:\s/, "");
data = data.replace(/"/g, "");

shjs.exec("git commit -s --author=\"" + data + "\" --message=\"" + msg + "\"");
})
}

function err(res) {
console.log("error:", res.message);
}



0 comments on commit a0b7181

Please sign in to comment.