Add github commit coverter. Change to double quotes
This commit is contained in:
parent
bd0a88c7dc
commit
a006277f26
|
@ -1,10 +1,10 @@
|
|||
const express = require('express');
|
||||
const express = require("express");
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
const convert = require('./util/convert');
|
||||
const convert = require("./util/convert");
|
||||
|
||||
app.get('/webhook/:provider', (req) => {
|
||||
app.get("/webhook/:provider", (req) => {
|
||||
const strategy = req.params.provider;
|
||||
const eventType = convert.getEvent[strategy](req.body);
|
||||
});
|
||||
app.listen(2000, () => console.log('Listening on port 2000'));
|
||||
app.listen(2000, () => console.log("Listening on port 2000"));
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
const github = function (body) {
|
||||
const github = function (data) {
|
||||
const noun = "commit" + data.commits.length > 1?"s":"";
|
||||
var text = data.commits.reduce((acc, curr, index) => {
|
||||
if (index < 6) {
|
||||
acc += `<a href='${curr.url}'>${curr.id.slice(0,6)}: ` +
|
||||
`${curr.message}</a>\n`;
|
||||
}
|
||||
return acc;
|
||||
}, `🔨 ${data.commits.length} ${noun}\n`);
|
||||
if (data.commits.length > 6) {
|
||||
text += `${data.commits.length - 6} more ${noun}.`;
|
||||
}
|
||||
return text;
|
||||
};
|
||||
|
||||
const gitlab = github;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const github = function (body) {
|
||||
if (body.commits && body.ref.match("^/refs/heads/") return "commit";
|
||||
if (body.commits && body.ref.match("^/refs/tags/") return "tag";
|
||||
if (body.commits && body.ref.match("^/refs/heads/")) return "commit";
|
||||
if (body.commits && body.ref.match("^/refs/tags/")) return "tag";
|
||||
if (body.issue) return "issue";
|
||||
};
|
||||
|
||||
module.exports = {github};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = {
|
||||
getEvent: require('./event'),
|
||||
commit: require('./commit'),
|
||||
getEvent: require("./event"),
|
||||
commit: require("./commit"),
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue