File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,14 +4,6 @@ var exec = require('child_process').exec;
44
55function execute ( cmd , cb ) {
66 exec ( cmd , function ( err , stdout , stderr ) {
7- if ( err ) {
8- console . error ( 'err' , err ) ;
9- }
10-
11- if ( stderr ) {
12- console . error ( 'err' , err ) ;
13- }
14-
157 cb ( stdout . split ( '\n' ) . join ( '' ) ) ;
168 } ) ;
179}
@@ -55,6 +47,16 @@ var GitInfo = {
5547 resolve ( data ) ;
5648 } ) ;
5749 } ) ;
50+ } ,
51+
52+ isOnBranch : function ( sha , branch ) {
53+ return new Bluebird ( function ( resolve ) {
54+ var command = 'git rev-list ' + branch + ' | grep ' + sha ;
55+
56+ execute ( command , function ( data ) {
57+ resolve ( data !== '' ) ;
58+ } ) ;
59+ } ) ;
5860 }
5961} ;
6062
Original file line number Diff line number Diff line change @@ -49,20 +49,25 @@ fs.removeAsync(config.screenshotRoot)
4949
5050 console . log ( 'Currently at' , branchInfo . branch , branchInfo . sha ) ;
5151
52- return gitInfo . getCommonAncestor ( branchInfo . sha , 'master' )
53- . then ( function ( ancestor ) {
54- if ( ancestor !== branchInfo . sha ) {
55- console . log ( 'diffing against' , ancestor ) ;
56- return startBuild ( {
57- project : config . project ,
58- head : branchInfo . sha ,
59- base : ancestor ,
60- numBrowsers : 1
61- } )
62- . then ( function ( build ) {
63- console . log ( 'Build started' , build . build ) ;
64- } ) ;
52+ return gitInfo . isOnBranch ( branchInfo . sha , 'master' )
53+ . then ( function ( isOnMaster ) {
54+ if ( isOnMaster ) {
55+ return ;
6556 }
57+
58+ return gitInfo . getCommonAncestor ( branchInfo . sha , 'master' )
59+ . then ( function ( ancestor ) {
60+ console . log ( 'diffing against' , ancestor ) ;
61+ return startBuild ( {
62+ project : config . project ,
63+ head : branchInfo . sha ,
64+ base : ancestor ,
65+ numBrowsers : 1
66+ } )
67+ . then ( function ( build ) {
68+ console . log ( 'Build started' , build . build ) ;
69+ } ) ;
70+ } ) ;
6671 } ) ;
6772} )
6873. then ( function ( ) {
You can’t perform that action at this time.
0 commit comments