File tree Expand file tree Collapse file tree 4 files changed +35
-15
lines changed Expand file tree Collapse file tree 4 files changed +35
-15
lines changed Original file line number Diff line number Diff line change @@ -30,15 +30,17 @@ public function parseRequest(): bool
3030 }
3131
3232 // fetch branch name
33- if (!empty ($ requestParams ['push ' ]['changes ' ][0 ]['new ' ]['name ' ])) {
34- $ branchParts = explode ('/ ' , $ requestParams ['push ' ]['changes ' ][0 ]['new ' ]['name ' ]);
35- $ this ->parameters ['branch ' ] = array_pop ($ branchParts );
33+ if (empty ($ requestParams ['push ' ]['changes ' ][0 ]['new ' ]['name ' ])) {
34+ return false ;
3635 }
36+ $ branchParts = explode ('/ ' , $ requestParams ['push ' ]['changes ' ][0 ]['new ' ]['name ' ]);
37+ $ this ->parameters ['branch ' ] = array_pop ($ branchParts );
3738
3839 // fetch revision hash
39- if (! empty ($ requestParams ['push ' ]['changes ' ][0 ]['new ' ]['target ' ]['hash ' ])) {
40- $ this -> parameters [ ' revision ' ] = $ requestParams [ ' push ' ][ ' changes ' ][ 0 ][ ' new ' ][ ' target ' ][ ' hash ' ] ;
40+ if (empty ($ requestParams ['push ' ]['changes ' ][0 ]['new ' ]['target ' ]['hash ' ])) {
41+ return false ;
4142 }
43+ $ this ->parameters ['revision ' ] = $ requestParams ['push ' ]['changes ' ][0 ]['new ' ]['target ' ]['hash ' ];
4244
4345 return true ;
4446 }
Original file line number Diff line number Diff line change @@ -26,13 +26,20 @@ public function parseRequest(): bool
2626 if (empty ($ requestParams )) {
2727 return false ;
2828 }
29- if (!empty ($ payload ['ref ' ])) {
30- $ branchParts = explode ('/ ' , $ payload ['ref ' ]);
31- $ this ->parameters ['branch ' ] = array_pop ($ branchParts );
29+
30+ // fetch branch name
31+ if (empty ($ requestParams ['ref ' ])) {
32+ return false ;
3233 }
33- if (!empty ($ payload ['after ' ])) {
34- $ this ->parameters ['revision ' ] = $ payload ['after ' ];
34+ $ branchParts = explode ('/ ' , $ requestParams ['ref ' ]);
35+ $ this ->parameters ['branch ' ] = array_pop ($ branchParts );
36+
37+ // fetch revision hash
38+ if (empty ($ requestParams ['after ' ])) {
39+ return false ;
3540 }
41+ $ this ->parameters ['revision ' ] = $ requestParams ['after ' ];
42+
3643 return true ;
3744 }
3845
Original file line number Diff line number Diff line change @@ -22,13 +22,23 @@ public function parseRequest(): bool
2222 return false ;
2323 }
2424 $ payload = json_decode ($ _REQUEST ['payload ' ], true );
25- if (!empty ($ payload ['ref ' ])) {
26- $ branchParts = explode ('/ ' , $ payload ['ref ' ]);
27- $ this ->parameters ['branch ' ] = array_pop ($ branchParts );
25+ if (empty ($ payload )) {
26+ return false ;
2827 }
29- if (!empty ($ payload ['after ' ])) {
30- $ this ->parameters ['revision ' ] = $ payload ['after ' ];
28+
29+ // fetch branch name
30+ if (empty ($ payload ['ref ' ])) {
31+ return false ;
3132 }
33+ $ branchParts = explode ('/ ' , $ payload ['ref ' ]);
34+ $ this ->parameters ['branch ' ] = array_pop ($ branchParts );
35+
36+ // fetch revision hash
37+ if (empty ($ payload ['after ' ])) {
38+ return false ;
39+ }
40+ $ this ->parameters ['revision ' ] = $ payload ['after ' ];
41+
3242 return true ;
3343 }
3444
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ public function handleRequest(): void
4646 {
4747 try {
4848 $ this ->parseRequest ();
49+ $ this ->logger ->debug ('API request parsed. ' , $ this ->requestParams );
4950 $ this ->validateRequest ();
5051 $ this ->executeRequest ();
5152 } catch (ShinyDeployException $ e ) {
You can’t perform that action at this time.
0 commit comments