Skip to content

Commit

Permalink
Allow for pushes to multiple branches
Browse files Browse the repository at this point in the history
  • Loading branch information
jbuck committed Jun 20, 2012
1 parent ab43872 commit 38e88da
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/server.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ function runJob(jobInfo, callback) {
scriptPath = shell.pwd()+'/on_'+jobInfo.event+'.js', scriptPath = shell.pwd()+'/on_'+jobInfo.event+'.js',
commandLine = 'node '+scriptPath+' > '+outputPath; commandLine = 'node '+scriptPath+' > '+outputPath;


if (jobInfo.event === 'push' && jobInfo.head_ref !== 'master') {
scriptPath = shell.pwd()+'/on_push_to_'+jobInfo.head_ref+'.js';
commandLine = 'node '+scriptPath+' > '+outputPath;
}

shell.mkdir('-p', jobInfo.public_dir); shell.mkdir('-p', jobInfo.public_dir);
shell.mkdir('-p', jobInfo.private_dir); shell.mkdir('-p', jobInfo.private_dir);


Expand Down Expand Up @@ -333,18 +338,21 @@ app.post('/', function(req, res) {
} }
}); // postComment() }); // postComment()
}; // maybeEnqueueJob() }; // maybeEnqueueJob()
break;


// //
// Event: push // Event: push
// //
case 'push': case 'push':
if (payload.ref !== 'refs/heads/master') { var ref = payload.ref.split('/')[2];
debug('push event not to master branch ('+payload.ref+'). skipping req');
if (ref === 'master' && !shell.test('-f', './on_push.js')) {
log('Command not implemented (push)');
return; return;
} }


if (!shell.test('-f', './on_push.js')) { if (ref !== 'master' && !shell.test('-f', './on_push_to_' + ref + '.js')) {
log('Command not implemented (push)'); log('Command not implemented (push_to_' + ref + ')');
return; return;
} }


Expand All @@ -358,7 +366,7 @@ app.post('/', function(req, res) {
public_url: 'http://'+config.host+':'+config.port+'/'+id, public_url: 'http://'+config.host+':'+config.port+'/'+id,
base_url: null, base_url: null,
head_url: 'git://github.com/'+config.repo+'.git', head_url: 'git://github.com/'+config.repo+'.git',
head_ref: 'master', head_ref: ref,
head_sha: payload.head_commit.id, head_sha: payload.head_commit.id,
debug: global.debug debug: global.debug
}; };
Expand Down

0 comments on commit 38e88da

Please sign in to comment.