Skip to content

Commit 80abff7

Browse files
iradulknownasilya
authored andcommitted
Enable commit status (#12)
1 parent d566fb5 commit 80abff7

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Strider Github Status
22

3-
This gives you nice notifications on pull-requests that are tested, letting you know if the tests would pass or fail on the merged code.
3+
This gives you nice notifications on pull-requests and commits that are tested, letting you know if the tests would pass or fail on the merged code.
44

55
### Requirements
66

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "strider-github-status",
33
"version": "2.0.0",
4-
"description": "Add build status indicators to pull requests in github",
4+
"description": "Add build status indicators to pull requests and commits in github",
55
"main": "index.js",
66
"repository": {
77
"type": "git",

worker.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ var debug = require('debug')('strider-github-status');
22

33
module.exports = {
44
init: function (config, job, context, callback) {
5+
var sha;
56
debug('initing', job._id, job.plugin_data);
6-
if (!job.plugin_data || !job.plugin_data.github || !job.plugin_data.github.pull_request) {
7-
debug('No github PR data', job.plugin_data, job);
8-
return callback(null, {});
9-
} else {
7+
if (job.plugin_data && job.plugin_data.github && job.plugin_data.github.pull_request) {
108
debug('found pr!', job.plugin_data.github.pull_request);
9+
sha = job.plugin_data.github.pull_request.sha;
10+
} else if (job.trigger.type === 'commit') {
11+
debug('found commit!', job.ref);
12+
sha = job.ref.id;
13+
} else {
14+
debug('No github PR data nor github commit', job.plugin_data, job);
15+
return callback(null, {});
1116
}
1217
var projectName = job.project.name;
1318
var creator = job.project.creator;
@@ -28,7 +33,7 @@ module.exports = {
2833
var github_repo_data = {
2934
user: job.project.provider.config.owner,
3035
repo: job.project.provider.config.repo,
31-
sha: job.plugin_data.github.pull_request.sha
36+
sha: sha
3237
};
3338
emitter.emit('plugin.github-status.started', job._id, projectName, token, github_repo_data, config);
3439
emitter.once('job.status.tested', function (jobId) {

0 commit comments

Comments
 (0)