Simplify handling of MRs updates;

This commit is contained in:
Benjamin Bouvier 2017-06-28 12:13:12 +02:00
parent 90440224ac
commit 90245819af

View File

@ -37,8 +37,6 @@ var client = new irc.Client(config.server, config.nick, {
retryDelay: 120000
});
var mergeRequests = {};
var app = express();
app.use(bodyParser.json()); // for parsing application/json
@ -137,25 +135,10 @@ var handlers = {
var url = request.url;
var state = request.state;
if (typeof mergeRequests[id] === 'undefined') {
mergeRequests[id] = {
state: state
};
// Stay silent if the merge request state is open and we didn't
// know it before.
if (state === "opened") {
// Don't trigger the hook on mr's updates.
if (request.action === 'update') {
return;
}
} else {
var formerState = mergeRequests[id].state;
mergeRequests[id].state = state;
// Abort if the state hasn't changed.
if (state === formerState) {
return;
}
}
shortenURL(url, function(shortUrl) {
var msg = projectName + ': MR# ' + id + ' (' + from + '->' + to + ': ' + title + ') ' +