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:
35
strategies/github.js
Normal file
35
strategies/github.js
Normal 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
5
strategies/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
|
||||
github: require("./github"),
|
||||
|
||||
};
|
Reference in New Issue
Block a user