From 5dd72fd196fb06d49939b943af84596d4cff5e25 Mon Sep 17 00:00:00 2001 From: liyuchun Date: Wed, 22 Dec 2021 09:51:13 +0800 Subject: [PATCH] * Adjust api create mr. --- module/extension/control.php | 7 ++++++- module/mr/model.php | 12 ++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/module/extension/control.php b/module/extension/control.php index 36d63875d6..34edece478 100644 --- a/module/extension/control.php +++ b/module/extension/control.php @@ -431,7 +431,12 @@ class extension extends control $tmpName = $_FILES['file']['tmp_name']; $fileName = $_FILES['file']['name']; $dest = $this->app->getTmpRoot() . "/extension/$fileName"; - move_uploaded_file($tmpName, $dest); + if(!move_uploaded_file($tmpName, $dest)) + { + $downloadPath = $this->app->getTmpRoot() . '/extension/'; + $errorMessage = strip_tags(sprintf($this->lang->extension->errorDownloadPathNotWritable, $downloadPath, $downloadPath)); + die(js::alert($errorMessage)); + } $extension = basename($fileName, '.zip'); $return = $this->extension->extractPackage($extension); diff --git a/module/mr/model.php b/module/mr/model.php index c27f908279..301abb55ee 100644 --- a/module/mr/model.php +++ b/module/mr/model.php @@ -187,10 +187,10 @@ class mrModel extends model public function apiCreate() { $postData = fixer::input('post') - ->setDefault('url,sourceBranch,targetBranch,diff,mergeStatus,hasNoConflict', '') + ->setDefault('repoUrl,repoSrcBranch,repoDistBranch,diffMsg,mergeStatus,hasNoConflict', '') ->get(); - $repo = $this->loadModel('repo')->getRepoByUrl($postData->url); + $repo = $this->loadModel('repo')->getRepoByUrl($postData->repoUrl); if(!$repo || $repo->result != 'fail') return false; $repo = (object)$repo->data; @@ -198,13 +198,13 @@ class mrModel extends model $MR = new stdClass(); $MR->gitlabID = $repo->client; $MR->sourceProject = $repo->path; - $MR->sourceBranch = $postData->sourceBranch; + $MR->sourceBranch = $postData->repoSrcBranch; $MR->targetProject = $repo->path; - $MR->targetBranch = $postData->taretBranch; - $MR->diffs = $postData->diff; + $MR->targetBranch = $postData->repoDistBranch; + $MR->diffs = $postData->diffMsg; $MR->title = 'Merge request'; $MR->repoID = $repo->id; - $MR->jobID = $postData->jobID; + $MR->jobID = $repo->job; $MR->synced = '0'; $MR->needCI = '1'; $MR->approvalStatus = 'approved';