* Fix bug #15009 and change config->MR to config->mr.

This commit is contained in:
Guan Xiying
2021-09-08 10:13:28 +08:00
parent 6ba818fd78
commit b305b8c752
8 changed files with 35 additions and 26 deletions
+19 -16
View File
@@ -1,19 +1,22 @@
<?php
$config->MR = new stdclass();
$config->MR->create = new stdclass();
$config->MR->create->requiredFields = 'gitlabID,sourceProject,sourceBranch,targetProject,targetBranch,title';
$config->MR->create->skippedFields = 'projectID';
$config->mr = new stdclass();
$config->mr->create->skippedFields = 'projectID';
$config->MR->maps = new stdclass;
$config->MR->maps->sync = array();
$config->MR->maps->sync['title'] = 'title|field|';
$config->MR->maps->sync['description'] = 'description|field|';
$config->MR->maps->sync['assignee'] = 'assignees|userPairs|id';
$config->MR->maps->sync['reviewer'] = 'reviewers|userPairs|id';
$config->MR->maps->sync['targetBranch'] = 'target_branch|field|';
$config->MR->maps->sync['sourceBranch'] = 'source_branch|field|';
$config->MR->maps->sync['sourceProject'] = 'source_project_id|field|';
$config->MR->maps->sync['targetProject'] = 'target_project_id|field|';
$config->MR->maps->sync['status'] = 'state|field|';
$config->MR->maps->sync['mergeStatus'] = 'merge_status|field|';
$config->mr->create = new stdclass();
$config->mr->create->requiredFields = 'gitlabID,sourceProject,sourceBranch,targetProject,targetBranch,title';
$config->mr->edit = new stdclass;
$config->mr->edit->requiredFields = 'gitlabID,sourceProject,sourceBranch,targetProject,targetBranch,title';
$config->mr->maps = new stdclass;
$config->mr->maps->sync = array();
$config->mr->maps->sync['title'] = 'title|field|';
$config->mr->maps->sync['description'] = 'description|field|';
$config->mr->maps->sync['assignee'] = 'assignees|userPairs|id';
$config->mr->maps->sync['reviewer'] = 'reviewers|userPairs|id';
$config->mr->maps->sync['targetBranch'] = 'target_branch|field|';
$config->mr->maps->sync['sourceBranch'] = 'source_branch|field|';
$config->mr->maps->sync['sourceProject'] = 'source_project_id|field|';
$config->mr->maps->sync['targetProject'] = 'target_project_id|field|';
$config->mr->maps->sync['status'] = 'state|field|';
$config->mr->maps->sync['mergeStatus'] = 'merge_status|field|';
+2 -1
View File
@@ -74,7 +74,8 @@ class mr extends control
/* Fetch user list both in Zentao and current GitLab project. */
$bindedUsers = $this->gitlab->getUserIdRealnamePairs($MR->gitlabID);
$rawProjectUsers = $this->gitlab->apiGetProjectUsers($MR->gitlabID, $MR->targetProject);
$users = array();
$users = array();
foreach($rawProjectUsers as $rawProjectUser)
{
if(!empty($bindedUsers[$rawProjectUser->id])) $users[$rawProjectUser->id] = $bindedUsers[$rawProjectUser->id];
+1 -1
View File
@@ -13,7 +13,7 @@ $lang->mr->viewInGitlab = 'view in GitLab';
$lang->mr->id = 'ID';
$lang->mr->mriid = "raw MR ID";
$lang->mr->name = 'Name';
$lang->mr->title = 'Name';
$lang->mr->status = 'Status';
$lang->mr->author = 'Author';
$lang->mr->assignee = 'Assignee';
+1 -1
View File
@@ -13,7 +13,7 @@ $lang->mr->viewInGitlab = '在GitLab查看';
$lang->mr->id = 'ID';
$lang->mr->mriid = "MR原始ID";
$lang->mr->name = '名称';
$lang->mr->title = '名称';
$lang->mr->status = '状态';
$lang->mr->author = '创建人';
$lang->mr->assignee = '指派给';
+9 -4
View File
@@ -84,8 +84,8 @@ class mrModel extends model
->add('createdDate', helper::now())
->get();
$this->dao->insert(TABLE_MR)->data($MR, $this->config->MR->create->skippedFields)
->batchCheck($this->config->MR->create->requiredFields, 'notempty')
$this->dao->insert(TABLE_MR)->data($MR, $this->config->mr->create->skippedFields)
->batchCheck($this->config->mr->create->requiredFields, 'notempty')
->autoCheck()
->exec();
if(dao::isError()) return array('result' => 'fail', 'message' => dao::getError());
@@ -173,6 +173,7 @@ class mrModel extends model
/* Update MR in Zentao database. */
$this->dao->update(TABLE_MR)->data($MR)
->where('id')->eq($MRID)
->batchCheck($this->config->mr->edit->requiredFields, 'notempty')
->autoCheck()
->exec();
$MR = $this->getByID($MRID);
@@ -194,7 +195,7 @@ class mrModel extends model
/* Sync MR in ZenTao database whatever status of MR in GitLab. */
if(isset($rawMR->iid))
{
$map = $this->config->MR->maps->sync;
$map = $this->config->mr->maps->sync;
$gitlabUsers = $this->gitlab->getUserIdAccountPairs($MR->gitlabID);
$newMR = new stdclass;
@@ -238,12 +239,13 @@ class mrModel extends model
{
if($MR->status != 'opened') continue;
$rawMR = $this->apiGetSingleMR($MR->gitlabID, $MR->targetProject, $MR->mriid);
if(isset($rawMR->iid))
{
/* create gitlab mr todo to zentao todo */
$this->batchSyncTodo($MR->gitlabID, $MR->targetProject);
$map = $this->config->MR->maps->sync;
$map = $this->config->mr->maps->sync;
$gitlabUsers = $this->gitlab->getUserIdAccountPairs($MR->gitlabID);
$newMR = new stdclass;
@@ -266,6 +268,9 @@ class mrModel extends model
if($value) $newMR->$syncField = $value;
}
if(empty((array)$newMR)) continue;
/* Update MR in Zentao database. */
$this->dao->update(TABLE_MR)->data($newMR)
->where('id')->eq($MR->id)
+1 -1
View File
@@ -31,7 +31,7 @@
<tr>
<?php $vars = "objectID=$objectID&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}"; ?>
<th class='w-60px text-left'><?php common::printOrderLink('id', $orderBy, $vars, $lang->mr->id); ?></th>
<th class='text-left'><?php common::printOrderLink('title', $orderBy, $vars, $lang->mr->name); ?></th>
<th class='text-left'><?php common::printOrderLink('title', $orderBy, $vars, $lang->mr->title); ?></th>
<th class='text-left'><?php common::printOrderLink('sourceProject', $orderBy, $vars, $lang->mr->sourceProject); ?></th>
<th class='w-100px text-left'><?php common::printOrderLink('sourceBranch', $orderBy, $vars, $lang->mr->sourceBranch); ?></th>
<th class='text-left'><?php common::printOrderLink('targetProject', $orderBy, $vars, $lang->mr->targetProject); ?></th>
+1 -1
View File
@@ -42,7 +42,7 @@
</td>
</tr>
<tr>
<th><?php echo $lang->mr->name;?></th>
<th><?php echo $lang->mr->title;?></th>
<td class='required'><?php echo html::input('title', '', "class='form-control'"); ?></td>
</tr>
<tr>
+1 -1
View File
@@ -44,7 +44,7 @@
</td>
</tr>
<tr>
<th><?php echo $lang->mr->name;?></th>
<th><?php echo $lang->mr->title;?></th>
<td class='required'><?php echo html::input('title', $MR->title, "class='form-control'"); ?></td>
</tr>
<tr>