Postreceive code reorganized

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 10 years ago
parent 80c1b3d57c
commit 5e8655b157
  1. 34
      BuildServer/routes/postreceive.js

@ -1,22 +1,13 @@
"use strict";
var builder = require('../lib/builder'); var builder = require('../lib/builder');
/* /*
* POST from github * POST from github
*/ */
module.exports = function (req, res) { var processPush = function (req, res, payload) {
if (!req.body || (!req.body.payload && !req.body.repository)) { var repository = payload.repository;
return res.end();
}
if (req.header("x-github-event") !== "push") {
console.log("Got '" + req.header("x-github-event") + "' event:");
//console.log(req.body);
return res.send("Only push events are supported");
}
var payload = req.body.payload ? JSON.parse(req.body.payload) : req.body,
repository = payload.repository;
builder.build({ builder.build({
app: req.app, app: req.app,
@ -33,3 +24,20 @@ module.exports = function (req, res) {
res.send("Done processing request from GitHub\r\n" + "Error: " + err + "\r\n" + "Result: " + result); res.send("Done processing request from GitHub\r\n" + "Error: " + err + "\r\n" + "Result: " + result);
}); });
}; };
module.exports = function (req, res) {
if (!req.body || (!req.body.payload && !req.body.repository)) {
return res.end();
}
var eventType = req.header("x-github-event"),
payload = req.body.payload ? JSON.parse(req.body.payload || "{}") : req.body;
if (eventType === "push") {
return processPush(req, res, payload);
}
console.log("Got '" + eventType + "' event:");
//console.log(req.body);
return res.send("Only push events are supported");
};

Loading…
Cancel
Save