Merge branch 'jihu'
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
$config->bug = new stdClass();
|
||||
$config->bug->batchCreate = 10;
|
||||
$config->bug->longlife = 7;
|
||||
$config->bug->removeFields= 'objectTypeList,productList,executionList,gitlabID,gitlabProjectID';
|
||||
|
||||
$config->bug->create = new stdclass();
|
||||
$config->bug->edit = new stdclass();
|
||||
|
||||
@@ -557,6 +557,13 @@ class bug extends control
|
||||
$this->view->customFields = $customFields;
|
||||
$this->view->showFields = $this->config->bug->custom->createFields;
|
||||
|
||||
/* Set gitlabProjects. */
|
||||
$allGitlabs = $this->loadModel('gitlab')->getPairs();
|
||||
$gitlabProjects = $this->loadModel('gitlab')->getProjectsByExecution($executionID);
|
||||
foreach($allGitlabs as $id => $name) if($id and !isset($gitlabProjects[$id])) unset($allGitlabs[$id]);
|
||||
$this->view->gitlabList = $allGitlabs;
|
||||
$this->view->gitlabProjects = $gitlabProjects;
|
||||
|
||||
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->create;
|
||||
$this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $this->products[$productID]);
|
||||
$this->view->position[] = $this->lang->bug->create;
|
||||
@@ -1457,6 +1464,13 @@ class bug extends control
|
||||
$bugs = $this->bug->getByList($bugIDList);
|
||||
foreach($bugs as $bugID => $bug)
|
||||
{
|
||||
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
|
||||
if(!empty($relation))
|
||||
{
|
||||
$currentIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
|
||||
if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug);
|
||||
}
|
||||
|
||||
if($bug->status != 'resolved')
|
||||
{
|
||||
if($bug->status != 'closed') $skipBugs[$bugID] = $bugID;
|
||||
@@ -1540,6 +1554,10 @@ class bug extends control
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Delete related issue in gitlab. */
|
||||
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
|
||||
if(!empty($relation)) $this->loadModel('gitlab')->deleteIssue('bug', $bugID, $relation->issueID);
|
||||
|
||||
$this->bug->delete(TABLE_BUG, $bugID);
|
||||
if($bug->toTask != 0)
|
||||
{
|
||||
|
||||
@@ -168,3 +168,23 @@ $(function()
|
||||
$(window).unload(function(){
|
||||
if(blockID) window.parent.refreshBlock($('#block' + blockID));
|
||||
});
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#gitlab').change(function()
|
||||
{
|
||||
host = $('#gitlab').val();
|
||||
if(host == '') return false;
|
||||
projects = '';
|
||||
$.each(gitlabProjects[host], function(id, obj){projects = projects + ',' + obj.gitlabProject});
|
||||
url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host + "&projects=" + projects);
|
||||
|
||||
$.get(url, function(response)
|
||||
{
|
||||
$('#gitlabProject').html('').append(response);
|
||||
$('#gitlabProject').chosen().trigger("chosen:updated");;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -24,6 +24,7 @@ $lang->bug->storyVersion = "{$lang->SRCommon}版本";
|
||||
$lang->bug->color = '标题颜色';
|
||||
$lang->bug->task = '相关任务';
|
||||
$lang->bug->title = 'Bug标题';
|
||||
$lang->bug->sync2gitlab = '同步gitlab';
|
||||
$lang->bug->severity = '严重程度';
|
||||
$lang->bug->severityAB = '级别';
|
||||
$lang->bug->pri = '优先级';
|
||||
|
||||
+82
-1
@@ -84,10 +84,13 @@ class bugModel extends model
|
||||
/* Use classic mode to replace required project. */
|
||||
if($this->config->systemMode == 'classic' and strpos($this->config->bug->create->requiredFields, 'project') !== false) $this->config->bug->create->requiredFields = str_replace('project', 'execution', $this->config->bug->create->requiredFields);
|
||||
|
||||
$this->dao->insert(TABLE_BUG)->data($bug)->autoCheck()->batchCheck($this->config->bug->create->requiredFields, 'notempty')->exec();
|
||||
$this->dao->insert(TABLE_BUG)->data($bug, $skip = 'gitlab,gitlabProject')->autoCheck()->batchCheck($this->config->bug->create->requiredFields, 'notempty')->exec();
|
||||
if(!dao::isError())
|
||||
{
|
||||
$bugID = $this->dao->lastInsertID();
|
||||
|
||||
$this->loadModel('gitlab')->apiCreateIssue($this->post->gitlab, $this->post->gitlabProject, 'bug', $bugID, $bug);
|
||||
|
||||
$this->file->updateObjectID($this->post->uid, $bugID, 'bug');
|
||||
$this->file->saveUpload('bug', $bugID);
|
||||
empty($bug->case) ? $this->loadModel('score')->create('bug', 'create', $bugID) : $this->loadModel('score')->create('bug', 'createFormCase', $bug->case);
|
||||
@@ -273,6 +276,32 @@ class bugModel extends model
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create bug from gitlab issue.
|
||||
*
|
||||
* @param object $bug
|
||||
* @param int $executionID
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function createBugFromGitlabIssue($bug, $executionID)
|
||||
{
|
||||
$bug->openedBy = $this->app->user->account;
|
||||
$bug->openedDate = helper::now(); // TODO(dingguodong) use from issue->created_at ?
|
||||
$bug->assignedDate = isset($bug->assignedTo) ? helper::now() : 0;
|
||||
$bug->openedBuild = 1;
|
||||
$bug->story = 0;
|
||||
$bug->task = 0;
|
||||
$bug->pri = 3;
|
||||
$bug->severity = 3;
|
||||
$bug->project = $this->dao->select('parent')->from(TABLE_EXECUTION)->where('id')->eq($executionID)->fetch('parent');
|
||||
|
||||
$this->dao->insert(TABLE_BUG)->data($bug, $skip = 'gitlab,gitlabProject')->autoCheck()->batchCheck($this->config->bug->create->requiredFields, 'notempty')->exec();
|
||||
if(!dao::isError()) return $this->dao->lastInsertID();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bugs.
|
||||
*
|
||||
@@ -645,6 +674,12 @@ class bugModel extends model
|
||||
|
||||
if(!empty($bug->resolvedBy)) $this->loadModel('score')->create('bug', 'resolve', $bugID);
|
||||
$this->file->updateObjectID($this->post->uid, $bugID, 'bug');
|
||||
|
||||
if(!empty($bug))
|
||||
{
|
||||
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
|
||||
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
|
||||
}
|
||||
return common::createChanges($oldBug, $bug);
|
||||
}
|
||||
}
|
||||
@@ -766,6 +801,10 @@ class bugModel extends model
|
||||
$this->executeHooks($bugID);
|
||||
|
||||
$allChanges[$bugID] = common::createChanges($oldBug, $bug);
|
||||
|
||||
/* update bug to gitlab issue. */
|
||||
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
|
||||
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -820,6 +859,12 @@ class bugModel extends model
|
||||
/* Update bugs. */
|
||||
foreach($activateBugs as $bugID => $bug)
|
||||
{
|
||||
if(!empty($bug))
|
||||
{
|
||||
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
|
||||
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', (Object)$bug, $bugID);
|
||||
}
|
||||
|
||||
$oldBug = $bugs[$bugID];
|
||||
$this->dao->update(TABLE_BUG)->data($bug, $skipFields = 'comment')->autoCheck()->where('id')->eq((int)$bugID)->exec();
|
||||
if(dao::isError()) die(js::error('bug#' . $bugID . dao::getError(true)));
|
||||
@@ -854,6 +899,15 @@ class bugModel extends model
|
||||
->autoCheck()
|
||||
->where('id')->eq($bugID)->exec();
|
||||
|
||||
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
|
||||
$bug = $this->getById($bugID); // get full bug object to update issue.
|
||||
$bug->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $bug->assignedTo);
|
||||
if($bug->assignee_id != '')
|
||||
{
|
||||
// TODO(dingguodong) we should alert to operator when can not find the user, and the operator should reconfigure user binding.
|
||||
$this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
|
||||
}
|
||||
|
||||
if(!dao::isError()) return common::createChanges($oldBug, $bug);
|
||||
}
|
||||
|
||||
@@ -908,6 +962,12 @@ class bugModel extends model
|
||||
$bug->lastEditedDate = $now;
|
||||
$bug->confirmed = 1;
|
||||
|
||||
if(!empty($bug))
|
||||
{
|
||||
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
|
||||
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
|
||||
}
|
||||
|
||||
$this->dao->update(TABLE_BUG)->data($bug)->where('id')->eq($bugID)->exec();
|
||||
$this->executeHooks($bugID);
|
||||
}
|
||||
@@ -991,6 +1051,7 @@ class bugModel extends model
|
||||
->checkIF($bug->resolution == 'fixed', 'resolvedBuild','notempty')
|
||||
->where('id')->eq((int)$bugID)
|
||||
->exec();
|
||||
|
||||
if(!dao::isError())
|
||||
{
|
||||
$this->loadModel('score')->create('bug', 'resolve', $oldBug);
|
||||
@@ -998,6 +1059,9 @@ class bugModel extends model
|
||||
/* Link bug to build and release. */
|
||||
$this->linkBugToBuild($bugID, $bug->resolvedBuild);
|
||||
|
||||
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
|
||||
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
|
||||
|
||||
return common::createChanges($oldBug, $bug);
|
||||
}
|
||||
|
||||
@@ -1127,6 +1191,10 @@ class bugModel extends model
|
||||
$this->dao->update(TABLE_BUG)->data($bug)->where('id')->eq($bugID)->exec();
|
||||
$this->executeHooks($bugID);
|
||||
|
||||
/* batch resolve issure bugs.*/
|
||||
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
|
||||
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
|
||||
|
||||
$changes[$bugID] = common::createChanges($oldBug, $bug);
|
||||
}
|
||||
|
||||
@@ -1178,11 +1246,18 @@ class bugModel extends model
|
||||
foreach($openedBuilds as $openedBuild)
|
||||
{
|
||||
$build = $this->build->getByID($openedBuild);
|
||||
if(empty($build)) continue;
|
||||
$build->bugs = trim(str_replace(",$bugID,", ',', ",$build->bugs,"), ',');
|
||||
$this->dao->update(TABLE_BUILD)->set('bugs')->eq($build->bugs)->where('id')->eq((int)$openedBuild)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($bug))
|
||||
{
|
||||
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
|
||||
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
|
||||
}
|
||||
|
||||
$bug->activatedCount += 1;
|
||||
return common::createChanges($oldBug, $bug);
|
||||
}
|
||||
@@ -1212,6 +1287,12 @@ class bugModel extends model
|
||||
|
||||
$this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->where('id')->eq((int)$bugID)->exec();
|
||||
|
||||
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
|
||||
if(!empty($relation))
|
||||
{
|
||||
$currentIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
|
||||
if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
|
||||
}
|
||||
return common::createChanges($oldBug, $bug);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ js::set('isStepsTemplate', $isStepsTemplate);
|
||||
js::set('oldProjectID', $projectID);
|
||||
js::set('blockID', $blockID);
|
||||
js::set('moduleID', $moduleID);
|
||||
js::set('gitlabProjects', $gitlabProjects);
|
||||
?>
|
||||
<div id="mainContent" class="main-content fade">
|
||||
<div class="center-block">
|
||||
@@ -312,6 +313,13 @@ js::set('moduleID', $moduleID);
|
||||
<?php endif;?>
|
||||
</tr>
|
||||
<?php endif;?>
|
||||
<?php if(!empty($gitlabProjects)):?>
|
||||
<tr>
|
||||
<th><?php echo $lang->task->sync2Gitlab;?></th>
|
||||
<td><?php echo html::select('gitlab', $gitlabList, '', "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('gitlabProject', '', '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<?php endif;?>
|
||||
<tr class='hide'>
|
||||
<th><?php echo $lang->bug->status;?></th>
|
||||
<td><?php echo html::hidden('status', 'active');?></td>
|
||||
|
||||
Reference in New Issue
Block a user