From 8a2c1207fd03f255457bbb9b36148881965141b2 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Wed, 2 Mar 2022 09:21:58 +0800 Subject: [PATCH] * Finish task #50075. --- module/gitlab/view/browse.html.php | 2 +- module/mr/model.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/module/gitlab/view/browse.html.php b/module/gitlab/view/browse.html.php index 0785c0d392..2d4fcde155 100644 --- a/module/gitlab/view/browse.html.php +++ b/module/gitlab/view/browse.html.php @@ -52,7 +52,7 @@ common::printLink('gitlab', 'browseGroup', "gitlabID=$id", " ", '', "title='{$lang->gitlab->browseGroup}' class='btn {$notBind}'"); common::printLink('gitlab', 'edit', "gitlabID=$id", " ", '',"title='{$lang->gitlab->edit}' class='btn btn-primary'"); common::printLink('gitlab', 'browseUser', "gitlabID=$id", " ", '', "title='{$lang->gitlab->browseUser}' class='btn {$disabled} {$notBind}' ,'disabled'"); - common::printLink('gitlab', 'bindUser', "id=$id", " ", '', "title='{$lang->gitlab->bindUser}' class='btn {$disabled} {$notBind}' ,'disabled'"); + common::printLink('gitlab', 'bindUser', "id=$id", " ", '', "title='{$lang->gitlab->bindUser}' class='btn {$disabled}' ,'disabled'"); if(common::hasPriv('gitlab', 'delete')) echo html::a($this->createLink('gitlab', 'delete', "gitlabID=$id"), '', 'hiddenwin', "title='{$lang->gitlab->delete}' class='btn'"); ?> diff --git a/module/mr/model.php b/module/mr/model.php index ebdb9a4321..415f3501da 100644 --- a/module/mr/model.php +++ b/module/mr/model.php @@ -747,9 +747,13 @@ class mrModel extends model */ public function apiAcceptMR($gitlabID, $projectID, $MRID, $sudo = "") { - $url = sprintf($this->gitlab->getApiRoot($gitlabID), "/projects/$projectID/merge_requests/$MRID/merge"); - if($sudo != "") return json_decode(commonModel::http($url, $data = null, $options = array(CURLOPT_CUSTOMREQUEST => 'PUT'), $headers = array("sudo: {$sudo}"))); - return json_decode(commonModel::http($url, $data = null, $options = array(CURLOPT_CUSTOMREQUEST => 'PUT'))); + $apiRoot = $this->gitlab->getApiRoot($gitlabID); + $approveUrl = sprintf($apiRoot, "/projects/$projectID/merge_requests/$MRID/approved"); + commonModel::http($approveUrl, null, array(CURLOPT_CUSTOMREQUEST => 'POST')); + + $url = sprintf($apiRoot, "/projects/$projectID/merge_requests/$MRID/merge"); + if($sudo != "") return json_decode(commonModel::http($url, null, array(CURLOPT_CUSTOMREQUEST => 'PUT'), $headers = array("sudo: {$sudo}"))); + return json_decode(commonModel::http($url, null, array(CURLOPT_CUSTOMREQUEST => 'PUT'))); } /**