Merge branch 'liyuchun_api' into 'master'
* Finish task #57065. See merge request easycorp/zentaopms!3982
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* The mr entry point of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2022 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author liyuchun <liyuchun@easysoft.ltd>
|
||||
* @package repo
|
||||
* @version 1
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class mrEntry extends baseEntry
|
||||
{
|
||||
/**
|
||||
* Create mr.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function post()
|
||||
{
|
||||
$fields = 'repoID,jobID,sourceBranch,targetBranch,diffs,mergeStatus';
|
||||
$this->batchSetPost($fields);
|
||||
$postData = fixer::input('post')->get();
|
||||
|
||||
$this->loadController('mr', 'create');
|
||||
$MRID = $this->loadModel('mr')->apiCreate();
|
||||
if(dao::isError()) $this->sendError(400, dao::getError());
|
||||
|
||||
$MR = $this->mr->getByID($MRID);
|
||||
$this->send(201, $MR);
|
||||
}
|
||||
}
|
||||
@@ -154,6 +154,7 @@ $routes['/docs/:id'] = 'doc';
|
||||
$routes['/repos'] = 'repos';
|
||||
$routes['/repos/rules'] = 'reporules';
|
||||
$routes['/jobs'] = 'jobs';
|
||||
$routes['/mr'] = 'mr';
|
||||
|
||||
$routes['/modules'] = 'modules';
|
||||
|
||||
|
||||
+11
-13
@@ -249,32 +249,30 @@ class mrModel extends model
|
||||
public function apiCreate()
|
||||
{
|
||||
$postData = fixer::input('post')->get();
|
||||
$postData = (object)$postData->data;
|
||||
|
||||
$repo = $this->loadModel('repo')->getRepoByUrl($postData->RepoUrl);
|
||||
if(empty($repo['data']))
|
||||
$repo = $this->dao->findByID($postData->repoID)->from(TABLE_REPO)->fetch();
|
||||
if(empty($repo))
|
||||
{
|
||||
dao::$errors[] = $repo['message'];
|
||||
dao::$errors[] = 'No matched gitlab.';
|
||||
return false;
|
||||
}
|
||||
$repo = $repo['data'];
|
||||
|
||||
/* Process and insert mr data. */
|
||||
$MR = new stdClass();
|
||||
$MR->gitlabID = $repo->client;
|
||||
$MR->sourceProject = $repo->path;
|
||||
$MR->sourceBranch = $postData->RepoSrcBranch;
|
||||
$MR->sourceBranch = $postData->sourceBranch;
|
||||
$MR->targetProject = $repo->path;
|
||||
$MR->targetBranch = $postData->RepoDistBranch;
|
||||
$MR->diffs = $this->post->data['DiffMsg'];
|
||||
$MR->title = $this->lang->mr->common . ' ' . $postData->RepoSrcBranch . $this->lang->mr->to . $postData->RepoDistBranch ;
|
||||
$MR->targetBranch = $postData->targetBranch;
|
||||
$MR->diffs = $postData->diffs;
|
||||
$MR->title = $this->lang->mr->common . ' ' . $postData->sourceBranch . $this->lang->mr->to . $postData->targetBranch ;
|
||||
$MR->repoID = $repo->id;
|
||||
$MR->jobID = isset($repo->job->id) ? $repo->job->id : 0;
|
||||
$MR->jobID = $postData->jobID;
|
||||
$MR->status = 'opened';
|
||||
$MR->synced = '0';
|
||||
$MR->needCI = '1';
|
||||
$MR->hasNoConflict = $postData->MergeStatus ? '0' : '1';
|
||||
$MR->mergeStatus = $postData->MergeStatus ? 'can_be_merged' : 'cannot_be_merged';
|
||||
$MR->hasNoConflict = $postData->mergeStatus ? '0' : '1';
|
||||
$MR->mergeStatus = $postData->mergeStatus ? 'can_be_merged' : 'cannot_be_merged';
|
||||
$MR->createdBy = $this->app->user->account;
|
||||
$MR->createdDate = date('Y-m-d H:i:s');
|
||||
|
||||
@@ -325,7 +323,7 @@ class mrModel extends model
|
||||
$this->dao->update(TABLE_MR)->data($newMR)->where('id')->eq($MRID)->autoCheck()->exec();
|
||||
if(dao::isError()) return false;
|
||||
}
|
||||
return true;
|
||||
return $MRID;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user