File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -842,24 +842,25 @@ public function gitlab($projectId)
842842
843843 $ results = [];
844844 $ status = 'failed ' ;
845- foreach ( $ payload [ ' commits ' ] as $ commit ) {
846- try {
847- $ branch = str_replace ( ' refs/heads/ ' , '' , $ payload [ ' ref ' ]);
848- $ committer = $ commit [ ' author ' ][ ' email ' ] ;
849- $ results [ $ commit ['id ' ]] = $ this -> createBuild (
850- Build:: SOURCE_WEBHOOK_PUSH ,
851- $ project ,
852- $ commit [ ' id ' ] ,
853- $ branch ,
854- null ,
855- $ committer ,
856- $ commit [ ' message ' ]
857- );
858- $ status = ' ok ' ;
859- } catch ( Exception $ ex ) {
860- $ results [ $ commit [ ' id ' ]] = [ ' status ' => ' failed ' , ' error ' => $ ex -> getMessage ()];
861- }
845+
846+ $ commit = end ( $ payload [ ' commits ' ]);
847+ try {
848+ $ branch = str_replace ( ' refs/heads/ ' , '' , $ payload [ ' ref ' ]) ;
849+ $ committer = $ commit ['author ' ][ ' email ' ];
850+ $ results [ $ commit [ ' id ' ]] = $ this -> createBuild (
851+ Build:: SOURCE_WEBHOOK_PUSH ,
852+ $ project ,
853+ $ commit [ ' id ' ] ,
854+ $ branch ,
855+ null ,
856+ $ committer ,
857+ $ commit [ ' message ' ]
858+ ) ;
859+ $ status = ' ok ' ;
860+ } catch ( Exception $ ex ) {
861+ $ results [ $ commit [ ' id ' ]] = [ ' status ' => ' failed ' , ' error ' => $ ex -> getMessage ()];
862862 }
863+
863864 return ['status ' => $ status , 'commits ' => $ results ];
864865 }
865866
You can’t perform that action at this time.
0 commit comments