@@ -16,34 +16,37 @@ const genTmpFolder = (subfix) => {
1616 return tmpPath
1717}
1818
19- const push = ( socket , topic , req ) => {
20- console . log ( { req} )
19+ const push = async ( socket , topic , req ) => {
2120 const triggerService = req . triggerService
2221 const webhook = req . webhook
2322 const repo = webhook . repository . full_name
2423 const tmpPath = genTmpFolder ( req . execution )
2524
25+ const sha = webhook . pullRequest ? webhook . pullRequest . head . sha : webhook . head_commit . id
26+
2627 report . progress ( socket , req , `Clonning ${ repo } ` , null )
28+ report . progress ( socket , req , `SHA ${ sha } ` , null )
2729 report . progress ( socket , req , `Temporal path ${ tmpPath } ` , null )
2830
2931 // Clone repository
30- git ( )
31- . clone ( `https://tideflow:${ triggerService . config . secret } @github.com/${ repo } ` , tmpPath )
32- . then ( result => {
33- delete req . webhook
34- report . result ( socket , req ,
35- {
36- stderr : null ,
37- stdout : 'Clone finished'
38- }
39- )
40- } )
41- . catch ( err => {
42- report . exception ( socket , req , err . toString ( ) )
43- } ) ;
32+ try {
33+ await git ( ) . clone ( `https://tideflow:${ triggerService . config . secret } @github.com/${ repo } ` , tmpPath )
34+ await git ( tmpPath ) . checkout ( sha )
35+ delete req . webhook
36+ report . result ( socket , req ,
37+ {
38+ stderr : null ,
39+ stdout : 'Clone finished'
40+ }
41+ )
42+ }
43+ catch ( ex ) {
44+ report . exception ( socket , req , ex . toString ( ) )
45+ }
4446}
4547
4648module . exports . push = push
49+ module . exports . pullRequest = push
4750
4851const test_cmd = async ( socket , topic , req ) => {
4952 const commands = req . cmd . split ( '\n' )
@@ -100,10 +103,9 @@ const test_cmd = async (socket, topic, req) => {
100103
101104 try {
102105 await Promise . all ( processCommands )
103- console . log ( 'all promises done' )
104106 report . result ( socket , req ,
105107 {
106- stdout : 'Clone finished'
108+ stdout : 'Execution finished'
107109 }
108110 )
109111 }
@@ -113,4 +115,5 @@ const test_cmd = async (socket, topic, req) => {
113115}
114116
115117module . exports . test_cmd = test_cmd
118+ module . exports . run_cmd = test_cmd
116119
0 commit comments