From 95c2adad703f2ca0f08f00104b8b2943b824e210 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 31 Aug 2021 10:57:17 +0800 Subject: [PATCH] * Correct apiAcceptMR and update functions. --- module/mr/model.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/module/mr/model.php b/module/mr/model.php index 1cba029e8f..bdb58b44dc 100644 --- a/module/mr/model.php +++ b/module/mr/model.php @@ -153,15 +153,16 @@ class mrModel extends model /* Update MR in GitLab. */ $newMR = new stdclass; - $newMR->title = $MR->title; - $newMR->description = $MR->description; - $newMR->assignee = $MR->assignee; - $newMR->reviewer = $MR->reviewer; - $newMR->targetBranch = $MR->targetBranch; + $newMR->title = $MR->title; + $newMR->description = $MR->description; + $newMR->assignee_ids = $MR->assignee; + $newMR->reviewer_ids = $MR->reviewer; + $newMR->target_branch = $MR->targetBranch; $oldMR = $this->getByID($MRID); - $this->apiUpdateMR($oldMR->gitlabID, $oldMR->targetProject, $oldMR->mriid, $newMR); + /* Known issue: `reviewer_ids` takes no effect. */ + $rawMR = $this->apiUpdateMR($oldMR->gitlabID, $oldMR->targetProject, $oldMR->mriid, $newMR); /* Change gitlab user ID to zentao account. */ $gitlabUsers = $this->gitlab->getUserIdAccountPairs($oldMR->gitlabID); @@ -173,6 +174,7 @@ class mrModel extends model ->where('id')->eq($MRID) ->autoCheck() ->exec(); + $MR = $this->getByID($MRID); if(dao::isError()) return array('result' => 'fail', 'message' => dao::getError()); return array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => helper::createLink('mr', 'browse')); @@ -314,8 +316,8 @@ class mrModel extends model */ public function apiAcceptMR($gitlabID, $projectID, $MRID) { - $url = sprintf($this->gitlab->getApiRoot($gitlabID), "/projects/$projectID/merge_requests/$MRID"); - return json_decode(commonModel::http($url, $data, $options = array(CURLOPT_CUSTOMREQUEST => 'PUT'))); + $url = sprintf($this->gitlab->getApiRoot($gitlabID), "/projects/$projectID/merge_requests/$MRID/merge"); + return json_decode(commonModel::http($url, array(), $options = array(CURLOPT_CUSTOMREQUEST => 'PUT'))); } /**