Rejigger message hooks;

This commit is contained in:
Benjamin Bouvier 2017-08-30 00:17:46 +02:00
parent daeb29868a
commit 7229764f18

View File

@ -72,7 +72,7 @@ if (config.lstu) {
var handlers = { var handlers = {
push: function(body, say) { push: function(body, say) {
var user = body.user_name; var user = body.user_username;
var projectName = body.project.name; var projectName = body.project.name;
var commits = body.commits; var commits = body.commits;
@ -95,22 +95,26 @@ var handlers = {
var action = 'created'; var action = 'created';
if (body.after === '0000000000000000000000000000000000000000') if (body.after === '0000000000000000000000000000000000000000')
action = 'deleted'; action = 'deleted';
msg = projectName + ': ' + user + ' ' + action + ' branch ' + branchName; msg = user + ' ' + action + ' branch ' + branchName + ' on ' + projectName + '.';
say(msg); say(msg);
} else { } else {
var maybeS = numCommits === 1 ? '' : 's'; var maybeS = numCommits === 1 ? '' : 's';
var lastCommit = commits[commits.length - 1]; var lastCommit = commits[commits.length - 1];
var lastCommitMessage = lastCommit.message.trim().split('\n')[0].trim(); var lastCommitMessage = lastCommit.message.trim().split('\n')[0].trim();
shortenURL(lastCommit.url, function(shortUrl) { shortenURL(lastCommit.url, function(shortUrl) {
msg = 'push on ' + projectName + '@' + branchName + ' (by ' + user + '): ' + msg = user ' pushed on ' + projectName + '@' + branchName + ': ';
commits.length + ' commit' + maybeS + ' (last: ' + lastCommitMessage + ') ' + shortUrl; if (numCommits === 1) {
msg += lastCommitMessage + ' ' + shortUrl;
} else {
msg += commits.length + ' commits (last: ' + lastCommitMessage + ') ' + shortUrl;
}
say(msg); say(msg);
}); });
} }
}, },
issue: function(body, say) { issue: function(body, say) {
var user = body.user.name; var user = body.user.username;
var projectName = body.project.name; var projectName = body.project.name;
var issue = body.object_attributes; var issue = body.object_attributes;
@ -124,13 +128,13 @@ var handlers = {
return; return;
shortenURL(url, function(shortUrl) { shortenURL(url, function(shortUrl) {
var msg = projectName + ': issue #' + issueNumber + ' ("' + issueTitle + '") changed state ("' + issueState + '") ' + shortUrl; var msg = user + ' ' + issue.action + 'd issue #' + issueNumber + ' ("' + issueTitle + '") on ' + projectName + ' ' + shortUrl;
say(msg); say(msg);
}); });
}, },
merge_request: function(body, say) { merge_request: function(body, say) {
var user = body.user.name; var user = body.user.username;
var request = body.object_attributes; var request = body.object_attributes;
@ -150,8 +154,8 @@ var handlers = {
} }
shortenURL(url, function(shortUrl) { shortenURL(url, function(shortUrl) {
var msg = projectName + ': MR# ' + id + ' (' + from + '->' + to + ': ' + title + ') ' + var msg = user + ' ' + request.action + ' MR !' + id + ' (' + from + '->' + to + ': ' + title + ') ' +
' has been ' + state + '; ' + shortUrl; ' on ' + projectName + '; ' + shortUrl;
say(msg); say(msg);
}); });
}, },