@@ -2,12 +2,17 @@ var debug = require('debug')('strider-github-status');
22
33module . 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