1
0
mirror of https://gitlab.com/ceda_ei/git-alerts-bot synced 2025-10-19 23:40:07 +02:00

[refactor] /util to /strategies

This commit is contained in:
Muthu Kumar
2018-11-27 22:36:29 +05:30
parent 1199d4e20d
commit abf043a27a
9 changed files with 54 additions and 52 deletions

35
strategies/github.js Normal file
View File

@@ -0,0 +1,35 @@
module.exports = {
event (data) {
if (data.commits && data.ref.match("^/refs/heads/")) return "commit";
if (data.commits && data.ref.match("^/refs/tags/")) return "tag";
if (data.issue) return "issue";
},
commit (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;
},
};

5
strategies/index.js Normal file
View File

@@ -0,0 +1,5 @@
module.exports = {
github: require("./github"),
};