Branch-Support for Codeship #309

This commit is contained in:
Nico Lindemann 2014-11-22 03:12:56 +01:00 committed by Thaddee Tyl
parent bfbe3cad50
commit 238b40d319

View File

@ -2073,13 +2073,14 @@ cache(function(data, match, sendBadge, request) {
})); }));
// Codeship.io integration // Codeship.io integration
camp.route(/^\/codeship\/(.+)\.(svg|png|gif|jpg|json)$/, camp.route(/^\/codeship\/([^\/]+)(?:\/(.+))?\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) { cache(function(data, match, sendBadge, request) {
var projectId = match[1]; // eg, `ab123456-00c0-0123-42de-6f98765g4h32`. var projectId = match[1]; // eg, `ab123456-00c0-0123-42de-6f98765g4h32`.
var format = match[2]; var format = match[3];
var branch = match[2];
var options = { var options = {
method: 'GET', method: 'GET',
uri: 'https://www.codeship.io/projects/' + projectId + '/status' uri: 'https://www.codeship.io/projects/' + projectId + '/status' + (branch != null ? '?branch=' + branch : '')
}; };
var badgeData = getBadgeData('build', data); var badgeData = getBadgeData('build', data);
request(options, function(err, res) { request(options, function(err, res) {
@ -2104,6 +2105,9 @@ cache(function(data, match, sendBadge, request) {
case 'projectnotfound': case 'projectnotfound':
badgeData.text[1] = 'not found'; badgeData.text[1] = 'not found';
break; break;
case 'branchnotfound':
badgeData.text[1] = 'branch not found';
break;
case 'testing': case 'testing':
case 'waiting': case 'waiting':
badgeData.text[1] = 'pending'; badgeData.text[1] = 'pending';