Merge branch 'test' into 'master'

add project name for a merge request

This fixes a bug.

See merge request !2
This commit is contained in:
Benjamin Bouvier 2016-06-23 22:28:02 +02:00
commit 1d1ef54c98
2 changed files with 30 additions and 9 deletions

5
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,5 @@
image: ubuntu:latest
job:
script:
- echo "Hello world!"

View File

@ -35,8 +35,7 @@ var handlers = {
if (commits.length < 4) {
msg = msg.concat(commits.map(formatCommit));
} else {
msg.push(formatCommit(commits[0]));
msg.push('...');
msg.push(formatCommit(commits[0]) + ' ...');
msg.push(formatCommit(commits[commits.length - 1]));
}
@ -54,8 +53,7 @@ var handlers = {
var url = issue.url;
var msg = [projectName + ': issue #' + issueNumber + ' has changed state ("' + issueState + '")'];
msg.push(issueTitle);
msg.push(url);
msg.push(issueTitle + ' ' + url);
return msg;
},
@ -65,6 +63,8 @@ var handlers = {
var request = body.object_attributes;
var projectName = request.target.name;
var from = request.source_branch;
var to = request.target_branch;
@ -74,14 +74,28 @@ var handlers = {
var state = request.state;
var msg = [projectName + ': merge request (' + from + ':' + to + ') #' + id + ' has changed state ("' + state + '")'];
msg.push(title);
msg.push(url);
msg.push(title + ' ' + url);
return msg;
},
build: function(body) {
console.log('build event NYI because not documented');
console.log(body);
return null;
var id = body.build_id;
var status = body.build_status;
var isFinished = body.build_finished_at !== null;
var duration = body.build_duration;
var projectName = body.project_name;
var stage = body.build_stage;
var msg = [];
msg.push(projectName + ': build #' + id + ' (' + stage + ') changed status: ' + status);
if (isFinished)
msg.push('build finished in ' + duration + ' seconds. ');
return msg;
}
};
@ -92,6 +106,8 @@ app.post('/', function(req, res) {
var msgs = null;
if (body.object_kind && handlers[body.object_kind])
msgs = handlers[body.object_kind](body);
else
console.log("Unexpected object_kind:", body.object_kind);
if (msgs) {
if (msgs instanceof Array) {