Simplify handling of MRs updates;
This commit is contained in:
parent
90440224ac
commit
90245819af
23
index.js
23
index.js
@ -37,8 +37,6 @@ var client = new irc.Client(config.server, config.nick, {
|
|||||||
retryDelay: 120000
|
retryDelay: 120000
|
||||||
});
|
});
|
||||||
|
|
||||||
var mergeRequests = {};
|
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
app.use(bodyParser.json()); // for parsing application/json
|
app.use(bodyParser.json()); // for parsing application/json
|
||||||
@ -137,24 +135,9 @@ var handlers = {
|
|||||||
var url = request.url;
|
var url = request.url;
|
||||||
var state = request.state;
|
var state = request.state;
|
||||||
|
|
||||||
if (typeof mergeRequests[id] === 'undefined') {
|
// Don't trigger the hook on mr's updates.
|
||||||
mergeRequests[id] = {
|
if (request.action === 'update') {
|
||||||
state: state
|
return;
|
||||||
};
|
|
||||||
|
|
||||||
// Stay silent if the merge request state is open and we didn't
|
|
||||||
// know it before.
|
|
||||||
if (state === "opened") {
|
|
||||||
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) {
|
shortenURL(url, function(shortUrl) {
|
||||||
|
Loading…
Reference in New Issue
Block a user