@@ -95,6 +95,42 @@ public function getLogger(){
95
95
public function parseRequest ($ rawRequest ){
96
96
$ this ->aRequest = collect (json_decode ($ rawRequest , true ));
97
97
98
+ /* Check if the Request comes from bitbucket
99
+ * An example payload can be found here: https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html#EventPayloads-Push
100
+ * */
101
+ if ($ this ->aRequest ->has ('push ' )){
102
+ $ aPush = $ this ->aRequest ->get ('push ' );
103
+ $ aRepository = $ this ->aRequest ->get ('repository ' );
104
+ $ aCommit = [];
105
+
106
+ foreach ($ aPush ['changes ' ] as $ aChange ){
107
+ foreach ($ aChange ['commits ' ] as $ commit ){
108
+
109
+ $ this ->aRequest ->put ('user_name ' , $ commit ['author ' ]['user ' ]['display_name ' ]);
110
+ $ this ->aRequest ->put ('before ' , $ aChange ['new ' ]['target ' ]['parents ' ][0 ]['hash ' ]);
111
+ $ this ->aRequest ->put ('after ' , $ aChange ['new ' ]['target ' ]['hash ' ]);
112
+
113
+ $ commit ['id ' ] = $ commit ['hash ' ];
114
+ $ commit ['timestamp ' ] = $ commit ['date ' ];
115
+ $ commit ['url ' ] = $ commit ['links ' ]['html ' ]['href ' ];
116
+ $ commit ['author ' ] = [
117
+ 'name ' => $ commit ['author ' ]['user ' ]['display_name ' ],
118
+ 'email ' => '' ,
119
+ ];
120
+
121
+ $ aCommit [] = $ commit ;
122
+ }
123
+ $ this ->aRequest ->put ('ref ' , 'ref/branch/ ' .$ aChange ['new ' ]['name ' ]);
124
+ }
125
+
126
+ $ aRepository ['description ' ] = '' ;
127
+ $ aRepository ['url ' ] = $ aRepository ['links ' ]['html ' ]['href ' ];
128
+ $ aRepository ['homepage ' ] = $ aRepository ['website ' ];
129
+
130
+ $ this ->aRequest ->put ('commits ' , $ aCommit );
131
+ $ this ->aRequest ->put ('repository ' , $ aRepository );
132
+ }
133
+
98
134
if ($ this ->aRequest ->has ('commits ' ))
99
135
$ this ->aRequest ->put ('commits ' , collect ($ this ->aRequest ->get ('commits ' )));
100
136
0 commit comments