From 7229764f1881b149add835548945ed0b8f01209d Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Wed, 30 Aug 2017 00:17:46 +0200 Subject: [PATCH] Rejigger message hooks; --- index.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 346bd9f..f3ba426 100644 --- a/index.js +++ b/index.js @@ -72,7 +72,7 @@ if (config.lstu) { var handlers = { push: function(body, say) { - var user = body.user_name; + var user = body.user_username; var projectName = body.project.name; var commits = body.commits; @@ -95,22 +95,26 @@ var handlers = { var action = 'created'; if (body.after === '0000000000000000000000000000000000000000') action = 'deleted'; - msg = projectName + ': ' + user + ' ' + action + ' branch ' + branchName; + msg = user + ' ' + action + ' branch ' + branchName + ' on ' + projectName + '.'; say(msg); } else { var maybeS = numCommits === 1 ? '' : 's'; var lastCommit = commits[commits.length - 1]; var lastCommitMessage = lastCommit.message.trim().split('\n')[0].trim(); shortenURL(lastCommit.url, function(shortUrl) { - msg = 'push on ' + projectName + '@' + branchName + ' (by ' + user + '): ' + - commits.length + ' commit' + maybeS + ' (last: ' + lastCommitMessage + ') ' + shortUrl; + msg = user ' pushed on ' + projectName + '@' + branchName + ': '; + if (numCommits === 1) { + msg += lastCommitMessage + ' ' + shortUrl; + } else { + msg += commits.length + ' commits (last: ' + lastCommitMessage + ') ' + shortUrl; + } say(msg); }); } }, issue: function(body, say) { - var user = body.user.name; + var user = body.user.username; var projectName = body.project.name; var issue = body.object_attributes; @@ -124,13 +128,13 @@ var handlers = { return; 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); }); }, merge_request: function(body, say) { - var user = body.user.name; + var user = body.user.username; var request = body.object_attributes; @@ -150,8 +154,8 @@ var handlers = { } shortenURL(url, function(shortUrl) { - var msg = projectName + ': MR# ' + id + ' (' + from + '->' + to + ': ' + title + ') ' + - ' has been ' + state + '; ' + shortUrl; + var msg = user + ' ' + request.action + ' MR !' + id + ' (' + from + '->' + to + ': ' + title + ') ' + + ' on ' + projectName + '; ' + shortUrl; say(msg); }); },