From b6192eb928eecd012e974aa4c1d212686220f36e Mon Sep 17 00:00:00 2001 From: lichengjun Date: Wed, 7 Jul 2021 16:35:21 +0800 Subject: [PATCH 01/34] * Add bug,task,story,model. --- module/bug/control.php | 9 +++++++++ module/bug/model.php | 25 +++++++++++++++++++++++-- module/story/model.php | 4 ++++ module/task/control.php | 6 ++++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 9594fcfbce..27feba41db 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -1464,6 +1464,15 @@ class bug extends control $bugs = $this->bug->getByList($bugIDList); foreach($bugs as $bugID => $bug) { + $relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID); + if(!empty($relation)) + { + $singleIssue = new stdclass(); + $singleIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->issueID); + + if($singleIssue->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; diff --git a/module/bug/model.php b/module/bug/model.php index 41a888416e..e5ff470a36 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -89,8 +89,7 @@ class bugModel extends model { $bugID = $this->dao->lastInsertID(); - $object = $this->getByID($bugID); - $this->loadModel('gitlab')->apiCreateIssue($this->post->gitlab, $this->post->gitlabProject, 'bug', $bugID, $object); + $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); @@ -824,6 +823,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); + } + $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))); @@ -920,6 +925,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); + } + $this->dao->update(TABLE_BUG)->data($bug)->where('id')->eq($bugID)->exec(); $this->executeHooks($bugID); } @@ -1143,6 +1154,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); + $changes[$bugID] = common::createChanges($oldBug, $bug); } @@ -1200,6 +1215,12 @@ class bugModel extends model } } + if(!empty($bug)) + { + $relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID); + if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug); + } + $bug->activatedCount += 1; return common::createChanges($oldBug, $bug); } diff --git a/module/story/model.php b/module/story/model.php index 4de8a83290..a5ed11130f 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1824,6 +1824,10 @@ class storyModel extends model $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec(); if(!dao::isError()) { + $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); + $story->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $story->assignedTo); + if($story->assignee_id != '') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story); + /* Push this story to gitlab issue. */ $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story); diff --git a/module/task/control.php b/module/task/control.php index f8b75ec28d..fa9dc689ac 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -572,6 +572,9 @@ class task extends control $task = $this->task->getByID($taskID); + $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); + $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); + $members = $this->loadModel('user')->getTeamMemberPairs($executionID, 'execution', 'nodeleted'); /* Compute next assignedTo. */ @@ -645,6 +648,9 @@ class task extends control if(isset($muletipleTasks[$taskID]) and $task->assignedTo != $this->app->user->account) continue; if(isset($muletipleTasks[$taskID]) and !isset($muletipleTasks[$taskID][$this->post->assignedTo])) continue; + $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); + $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); + $changes = $this->task->assign($taskID); if(dao::isError()) die(js::error(dao::getError())); $actionID = $this->action->create('task', $taskID, 'Assigned', $this->post->comment, $this->post->assignedTo); From e9bcb88d9edb3949c3b0f98a0d9f7eb47193c5c6 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Wed, 7 Jul 2021 17:09:04 +0800 Subject: [PATCH 02/34] * Rename saveSyncedIssue to saveIssueRelation, add func doc. --- module/gitlab/control.php | 2 +- module/gitlab/model.php | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 5dfc931326..0a1b249532 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -247,7 +247,7 @@ class gitlab extends control a($relations);exit; $issue = $this->gitlab->taskToIssue($gitlabID, $projectID, $task); $issue = $this->gitlab->apiCreateIssue($gitlabID, $projectID, $issue); - $this->gitlab->saveSyncedIssue('task', $task, $gitlabID, $issue); + $this->gitlab->saveIssueRelation('task', $task, $gitlabID, $issue); exit; } diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 85dce8be52..dc541da4eb 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -546,6 +546,15 @@ class gitlabModel extends model return json_decode(commonModel::http($url)); } + /** + * Get gitlab issues by api. + * + * @param int $gitlabID + * @param int $projectID + * @param string $options + * @access public + * @return object + */ public function apiGetIssues($gitlabID, $projectID, $options = null) { // TODO(dingguodong) not pagination yet. @@ -588,7 +597,7 @@ class gitlabModel extends model $response = json_decode(commonModel::http($url, $issue)); if(!$response) return false; - return $this->saveSyncedIssue($objectType, $object, $gitlabID, $response); + return $this->saveIssueRelation($objectType, $object, $gitlabID, $response); } /** @@ -901,7 +910,7 @@ class gitlabModel extends model * @access public * @return void */ - public function saveSyncedIssue($objectType, $object, $gitlabID, $issue) + public function saveIssueRelation($objectType, $object, $gitlabID, $issue) { if(empty($issue->iid) or empty($issue->project_id)) return false; @@ -939,7 +948,7 @@ class gitlabModel extends model $apiRoot = $this->getApiRoot($gitlabID); $url = sprintf($apiRoot, "/projects/{$projectID}/issues/{$issue->iid}"); commonModel::http($url, $data, $options = array(CURLOPT_CUSTOMREQUEST => 'PUT')); - $this->saveSyncedIssue($objectType, $object, $gitlabID, $issue); + $this->saveIssueRelation($objectType, $object, $gitlabID, $issue); } /** From 47e3c473a1d6c084e3cf146947499954b3eb963e Mon Sep 17 00:00:00 2001 From: dingguodong Date: Wed, 7 Jul 2021 17:16:06 +0800 Subject: [PATCH 03/34] * Put strings in long line to config file. --- module/task/config.php | 1 + module/task/model.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/module/task/config.php b/module/task/config.php index 5db5eb88ae..ab950c3b2e 100644 --- a/module/task/config.php +++ b/module/task/config.php @@ -26,6 +26,7 @@ $config->task->editor->activate = array('id' => 'comment', 'tools' => 'simpleToo $config->task->editor->cancel = array('id' => 'comment', 'tools' => 'simpleTools'); $config->task->editor->pause = array('id' => 'comment', 'tools' => 'simpleTools'); +$config->task->removeFields = 'objectTypeList,productList,executionList,gitlabID,gitlabProjectID,after,files,labels,assignedTo,uid,storyEstimate,storyDesc,storyPri,team,teamEstimate,teamMember,multiple,teams,contactListMenu,selectTestStory,testStory,testPri,testEstStarted,testDeadline,testAssignedTo,testEstimate,sync'; $config->task->exportFields = ' id, execution, module, story, name, desc, diff --git a/module/task/model.php b/module/task/model.php index 62890a2386..770e973774 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -489,7 +489,7 @@ class taskModel extends model ->cleanINT('execution,story,module') ->stripTags($this->config->task->editor->create['id'], $this->config->allowedTags) ->join('mailto', ',') - ->remove('objectTypeList,productList,executionList,gitlabID,gitlabProjectID,after,files,labels,assignedTo,uid,storyEstimate,storyDesc,storyPri,team,teamEstimate,teamMember,multiple,teams,contactListMenu,selectTestStory,testStory,testPri,testEstStarted,testDeadline,testAssignedTo,testEstimate,sync') + ->remove($this->config->task->removeFields) ->add('version', 1) ->get(); From b42bc4afc977e6e4dbd99b61ac60f3dfed640392 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Wed, 7 Jul 2021 17:29:53 +0800 Subject: [PATCH 04/34] * Optimize url parameter. --- config/filter.php | 1 + module/gitlab/control.php | 8 ++++---- module/repo/view/maintain.html.php | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/config/filter.php b/config/filter.php index 7460c2a0da..42bd625242 100644 --- a/config/filter.php +++ b/config/filter.php @@ -321,4 +321,5 @@ $filter->gitlab->importissue->get['gitlab'] = 'int'; $filter->gitlab->importissue->get['product'] = 'int'; $filter->gitlab->importissue->get['product'] = 'string'; $filter->gitlab->importissue->get['project'] = 'int'; +$filter->gitlab->importissue->get['repo'] = 'int'; diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 0a1b249532..0fa6a04612 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -259,10 +259,10 @@ class gitlab extends control */ public function importIssue() { - $productIDList = explode(',', $this->get->product); - $gitlabID = $this->get->gitlab; - $projectID = $this->get->project; - + $repo = $this->loadModel('repo')->getRepoByID($this->get->repo); + $productIDList = explode(',', $repo->product); + $gitlabID = $repo->gitlab; + $projectID = $repo->project; if($_POST) { diff --git a/module/repo/view/maintain.html.php b/module/repo/view/maintain.html.php index d59a9a4186..4f754db09f 100644 --- a/module/repo/view/maintain.html.php +++ b/module/repo/view/maintain.html.php @@ -49,7 +49,7 @@ id&objectID=$objectID", '', 'list', 'edit'); - common::printIcon('gitlab', 'importissue', "product={$repo->product}&gitlab={$repo->gitlab}&project={$repo->project}", '', 'list', 'link'); + common::printIcon('gitlab', 'importissue', "repo={$repo->id}", '', 'list', 'link'); if(common::hasPriv('repo', 'delete')) echo html::a($this->createLink('repo', 'delete', "repoID=$repo->id&objectID=$objectID"), '', 'hiddenwin', "title='{$lang->repo->delete}' class='btn'"); ?> From 90d5f86b612bc13799262ef5389a9694201639f1 Mon Sep 17 00:00:00 2001 From: lichengjun Date: Wed, 7 Jul 2021 17:41:07 +0800 Subject: [PATCH 05/34] * Fix close funciton code. --- module/bug/control.php | 6 ++---- module/bug/model.php | 9 ++------- module/gitlab/model.php | 2 +- module/story/model.php | 9 ++++----- module/task/model.php | 17 ++++++----------- 5 files changed, 15 insertions(+), 28 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 27feba41db..3f87585bcb 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -1467,10 +1467,8 @@ class bug extends control $relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID); if(!empty($relation)) { - $singleIssue = new stdclass(); - $singleIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->issueID); - - if($singleIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug); + $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') diff --git a/module/bug/model.php b/module/bug/model.php index e5ff470a36..d9e90aff41 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1253,13 +1253,8 @@ class bugModel extends model $relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID); if(!empty($relation)) { - $singleIssue = new stdclass(); - $singleIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->issueID); - - if($singleIssue->state != 'closed') - { - $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug); - } + $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); } return common::createChanges($oldBug, $bug); } diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 85dce8be52..2a5808df8a 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -543,7 +543,7 @@ class gitlabModel extends model public function apiGetSingleIssue($gitlabID, $projectID, $issueID) { $url = sprintf($this->getApiRoot($gitlabID), "/projects/$projectID/issues/{$issueID}"); - return json_decode(commonModel::http($url)); + $aaa = json_decode(commonModel::http($url)); } public function apiGetIssues($gitlabID, $projectID, $options = null) diff --git a/module/story/model.php b/module/story/model.php index a5ed11130f..9e998cb7b8 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1434,9 +1434,8 @@ class storyModel extends model if(!empty($relation)) { - $singleIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->issueID); - - if($singleIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story); + $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, 'story', $story); } /* Update parent story status. */ @@ -1509,8 +1508,8 @@ class storyModel extends model $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); if(!empty($relation)) { - $singleIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->issueID); - if($singleIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story); + $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, 'story', $story); } } else diff --git a/module/task/model.php b/module/task/model.php index 62890a2386..8b2c30ba8f 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -1730,9 +1730,8 @@ class taskModel extends model $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); if(!empty($relation)) { - $singleIssue = new stdclass(); - $singleIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->issueID); - if($singleIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); + $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, 'task', $task); } if($oldTask->parent > 0) $this->updateParentStatus($taskID); @@ -1794,10 +1793,8 @@ class taskModel extends model $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); if(!empty($relation)) { - $singleIssue = new stdclass(); - $singleIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->issueID); - - if($singleIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $task); + $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', $task); } if(!dao::isError()) @@ -1847,10 +1844,8 @@ class taskModel extends model $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); if(!empty($relation)) { - $singleIssue = new stdclass(); - $singleIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->issueID); - - if($singleIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); + $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, 'task', $task); } if(!dao::isError()) return common::createChanges($oldTask, $task); From de848b9faf23f0ffb68b44f0e17368ac7f52fd44 Mon Sep 17 00:00:00 2001 From: lichengjun Date: Thu, 8 Jul 2021 09:29:29 +0800 Subject: [PATCH 06/34] * Fix code format. --- module/gitlab/model.php | 4 ++-- module/task/control.php | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 1108b86548..85dc58983d 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -543,7 +543,7 @@ class gitlabModel extends model public function apiGetSingleIssue($gitlabID, $projectID, $issueID) { $url = sprintf($this->getApiRoot($gitlabID), "/projects/$projectID/issues/{$issueID}"); - $aaa = json_decode(commonModel::http($url)); + return json_decode(commonModel::http($url)); } /** @@ -583,7 +583,7 @@ class gitlabModel extends model public function apiCreateIssue($gitlabID, $projectID, $objectType, $objectID, $object) { $label = $this->createZentaoObjectLabel($gitlabID, $projectID, $objectType, $objectID); - + if(!isset($object->id)) $object->id = $objectID; $issue = $this->loadModel('gitlab')->parseObjectToIssue($gitlabID, $projectID, $objectType, $object); if(isset($label->name)) $issue->labels = $label->name; foreach($this->config->gitlab->skippedFields->issueCreate[$objectType] as $field) diff --git a/module/task/control.php b/module/task/control.php index fa9dc689ac..5ec982cb8d 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -649,8 +649,7 @@ class task extends control if(isset($muletipleTasks[$taskID]) and !isset($muletipleTasks[$taskID][$this->post->assignedTo])) continue; $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); - $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); - + if(!empty($task))$this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); $changes = $this->task->assign($taskID); if(dao::isError()) die(js::error(dao::getError())); $actionID = $this->action->create('task', $taskID, 'Assigned', $this->post->comment, $this->post->assignedTo); From 882f7195fdde44e7dd64aaaaaa13d93a786d677f Mon Sep 17 00:00:00 2001 From: dingguodong Date: Thu, 8 Jul 2021 10:54:23 +0800 Subject: [PATCH 07/34] * Keep uniformed style for fixer removal action. --- module/task/config.php | 2 +- module/task/model.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/module/task/config.php b/module/task/config.php index ab950c3b2e..cb5c12a616 100644 --- a/module/task/config.php +++ b/module/task/config.php @@ -26,7 +26,7 @@ $config->task->editor->activate = array('id' => 'comment', 'tools' => 'simpleToo $config->task->editor->cancel = array('id' => 'comment', 'tools' => 'simpleTools'); $config->task->editor->pause = array('id' => 'comment', 'tools' => 'simpleTools'); -$config->task->removeFields = 'objectTypeList,productList,executionList,gitlabID,gitlabProjectID,after,files,labels,assignedTo,uid,storyEstimate,storyDesc,storyPri,team,teamEstimate,teamMember,multiple,teams,contactListMenu,selectTestStory,testStory,testPri,testEstStarted,testDeadline,testAssignedTo,testEstimate,sync'; +$config->task->removeFields = 'objectTypeList,productList,executionList,gitlabID,gitlabProjectID'; $config->task->exportFields = ' id, execution, module, story, name, desc, diff --git a/module/task/model.php b/module/task/model.php index b83c8b74f7..a9615b9f59 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -489,6 +489,7 @@ class taskModel extends model ->cleanINT('execution,story,module') ->stripTags($this->config->task->editor->create['id'], $this->config->allowedTags) ->join('mailto', ',') + ->remove('after,files,labels,assignedTo,uid,storyEstimate,storyDesc,storyPri,team,teamEstimate,teamMember,multiple,teams,contactListMenu,selectTestStory,testStory,testPri,testEstStarted,testDeadline,testAssignedTo,testEstimate,sync') ->remove($this->config->task->removeFields) ->add('version', 1) ->get(); From 832e9b1cf1fc256fdf770a36b67d383bd60b0e0e Mon Sep 17 00:00:00 2001 From: dingguodong Date: Thu, 8 Jul 2021 11:25:14 +0800 Subject: [PATCH 08/34] * Optimize code when value is null. --- module/gitlab/model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 85dc58983d..f4cba5b9c2 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -1154,8 +1154,8 @@ class gitlabModel extends model if(!isset($changes->$gitlabField) and $object->id != 0) continue; if($optionType == 'field') $value = $issue->$gitlabField; if($optionType == 'field') $value = $issue->$gitlabField; - if($options == 'date') $value = date('Y-m-d', strtotime($value)); - if($options == 'datetime') $value = date('Y-m-d H:i:s', strtotime($value)); + if($options == 'date') $value = $value ? date('Y-m-d', strtotime($value)) : '0000-00-00'; + if($options == 'datetime') $value = $value ? date('Y-m-d H:i:s', strtotime($value)) : '0000-00-00 00:00:00'; if($optionType == 'userPairs' and isset($issue->$gitlabField)) $value = zget($gitlabUsers, $issue->$gitlabField); if($optionType == 'configItems' and isset($issue->$gitlabField)) $value = array_search($issue->$gitlabField, $this->config->gitlab->$options); if($value) $object->$zentaoField = $value; From 129e14bf30be90d86d2bf04782b210fa5ed97db7 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Thu, 8 Jul 2021 14:30:28 +0800 Subject: [PATCH 09/34] * Finish importing issue to zentao bug(staging). --- module/bug/config.php | 1 + module/bug/model.php | 45 ++++++++++++++++++++++++++++++++++++ module/gitlab/config.php | 1 + module/gitlab/control.php | 22 ++++++++++++++---- module/gitlab/lang/zh-cn.php | 1 + 5 files changed, 65 insertions(+), 5 deletions(-) diff --git a/module/bug/config.php b/module/bug/config.php index ab1efb6707..bc508859ab 100644 --- a/module/bug/config.php +++ b/module/bug/config.php @@ -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(); diff --git a/module/bug/model.php b/module/bug/model.php index d9e90aff41..d481824988 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -273,6 +273,51 @@ 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) + { + foreach($bug as $feild => $value) $_POST[$feild] = $value; + $now = helper::now(); + $bug = fixer::input('post') + ->setDefault('openedBy', $this->app->user->account) + ->setDefault('openedDate', $now) + ->setDefault('project,execution,story,task', 0) + ->setDefault('openedBuild', '1') // todo(dingguodong) openedBuild is hard-coded. + ->setDefault('deadline', '0000-00-00') + ->setIF($this->config->systemMode == 'new' && $this->lang->navGroup->bug != 'qa', 'project', $this->session->project) + ->setIF(strpos($this->config->bug->create->requiredFields, 'deadline') !== false, 'deadline', $bug->deadline) + ->setIF(isset($bug->assignedTo) and $bug->assignedTo != '', 'assignedDate', $now) + ->stripTags($this->config->bug->editor->create['id'], $this->config->allowedTags) + ->cleanInt('product,execution,module,severity') + ->join('openedBuild', ',') + ->join('mailto', ',') + ->remove('files, labels,uid,oldTaskID,contactListMenu') + ->remove($this->config->bug->removeFields) + ->get(); + + if($executionID != 0) + { + $bug->project = $this->dao->select('parent')->from(TABLE_EXECUTION)->where('id')->eq($executionID)->fetch('parent'); + $bug->execution = $executionID; + } + + $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(); + return $bugID; + } + + return false; + } + /** * Get bugs. * diff --git a/module/gitlab/config.php b/module/gitlab/config.php index f3fff35b4d..84ee284a8d 100644 --- a/module/gitlab/config.php +++ b/module/gitlab/config.php @@ -55,6 +55,7 @@ $config->gitlab->maps->bug = array(); $config->gitlab->maps->bug['title'] = 'title|field|'; $config->gitlab->maps->bug['steps'] = 'description|field|'; $config->gitlab->maps->bug['openedDate'] = 'created_at|field|datetime'; +$config->gitlab->maps->bug['deadline'] = 'due_date|field|date'; $config->gitlab->maps->bug['assignedTo'] = 'assignee_id|userPairs|'; $config->gitlab->maps->bug['status'] = 'state|configItems|bugStateMap'; $config->gitlab->maps->bug['pri'] = 'weight|configItems|bugWeightMap'; diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 0fa6a04612..11a3aed968 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -269,6 +269,8 @@ class gitlab extends control $executionList = $this->post->executionList; $objectTypeList = $this->post->objectTypeList; $productList = $this->post->productList; + + $failedIssues = array(); foreach($executionList as $issueID => $executionID) { if($executionID) @@ -281,6 +283,8 @@ class gitlab extends control $issue->updated_by_id = $issue->author->id; // here can be replaced by current zentao user. $object = $this->gitlab->issueToZentaoObject($issue, $gitlabID); + $object->product = $productList[$issueID]; + $object->execution = $executionID; if($objectType == 'task') { $objectID = $this->loadModel('task')->createTaskFromGitlabIssue($object, $executionID); @@ -288,23 +292,31 @@ class gitlab extends control if($objectType == 'bug') { + $objectID = $this->loadModel('bug')->createBugFromGitlabIssue($object, $executionID); } if($objectType == 'story') { + $objectID = $this->loadModel('story')->createStoryFromGitlabIssue($object, $executionID); } - - $object->id = $objectID; - $object->product = $productList[$issueID]; - $object->execution = $executionID; - $this->gitlab->saveImportedIssue($gitlabID, $projectID, $objectType, $objectID, $issue, $object); + if($objectID) + { + $object->id = $objectID; + $this->gitlab->saveImportedIssue($gitlabID, $projectID, $objectType, $objectID, $issue, $object); + } + else + { + $failedIssues[] = $issue->iid; + } } else { if($productList[$issueID] != 0) $this->send(array('result' => 'fail', 'message' => $this->lang->gitlab->importIssueError, 'locate' => $this->server->http_referer)); } } + + if($failedIssues) $this->send(array('result' => 'success', 'message' => $this->lang->gitlab->importIssueWarn, 'locate' => $this->server->http_referer)); $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->server->http_referer)); } diff --git a/module/gitlab/lang/zh-cn.php b/module/gitlab/lang/zh-cn.php index 6c5e6ad25d..e2df334a72 100644 --- a/module/gitlab/lang/zh-cn.php +++ b/module/gitlab/lang/zh-cn.php @@ -40,3 +40,4 @@ $lang->gitlab->tokenError = "当前token非管理员权限。"; $lang->gitlab->hostError = "无效的gitlab服务地址。"; $lang->gitlab->bindUserError = "不能重复绑定用户 %s"; $lang->gitlab->importIssueError = "未选择该议题所属的执行。"; +$lang->gitlab->importIssueWarn = "存在导入失败的议题,可再次尝试导入。"; From 5c25aba4c664ecf74266de1f190942791352289e Mon Sep 17 00:00:00 2001 From: lichengjun Date: Thu, 8 Jul 2021 14:46:27 +0800 Subject: [PATCH 10/34] * Fix task code bug. --- module/task/control.php | 4 +--- module/task/model.php | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/module/task/control.php b/module/task/control.php index 5ec982cb8d..64da0f0f6a 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -647,9 +647,7 @@ class task extends control { if(isset($muletipleTasks[$taskID]) and $task->assignedTo != $this->app->user->account) continue; if(isset($muletipleTasks[$taskID]) and !isset($muletipleTasks[$taskID][$this->post->assignedTo])) continue; - - $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); - if(!empty($task))$this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); + $changes = $this->task->assign($taskID); if(dao::isError()) die(js::error(dao::getError())); $actionID = $this->action->create('task', $taskID, 'Assigned', $this->post->comment, $this->post->assignedTo); diff --git a/module/task/model.php b/module/task/model.php index b83c8b74f7..a17ae4b1a9 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -1389,8 +1389,7 @@ class taskModel extends model ->where('id')->eq($taskID)->exec(); $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); - $task->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $task->assignedTo); - if($task->assignee_id != '') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, $task); + if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $oldTask); if(!dao::isError()) return common::createChanges($oldTask, $task); } From 9e76157a0c228c9e248ab668ecdaab8db359fb5e Mon Sep 17 00:00:00 2001 From: dingguodong Date: Thu, 8 Jul 2021 14:54:18 +0800 Subject: [PATCH 11/34] * Put product into removal field and bug fix. --- module/task/config.php | 2 +- module/task/model.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/module/task/config.php b/module/task/config.php index cb5c12a616..67fe4ffabc 100644 --- a/module/task/config.php +++ b/module/task/config.php @@ -26,7 +26,7 @@ $config->task->editor->activate = array('id' => 'comment', 'tools' => 'simpleToo $config->task->editor->cancel = array('id' => 'comment', 'tools' => 'simpleTools'); $config->task->editor->pause = array('id' => 'comment', 'tools' => 'simpleTools'); -$config->task->removeFields = 'objectTypeList,productList,executionList,gitlabID,gitlabProjectID'; +$config->task->removeFields = 'objectTypeList,productList,executionList,gitlabID,gitlabProjectID,product'; $config->task->exportFields = ' id, execution, module, story, name, desc, diff --git a/module/task/model.php b/module/task/model.php index a9615b9f59..fc82302bc5 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -1391,7 +1391,7 @@ class taskModel extends model $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); $task->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $task->assignedTo); - if($task->assignee_id != '') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, $task); + if($task->assignee_id != '') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); if(!dao::isError()) return common::createChanges($oldTask, $task); } From 6af64c8c1273e7b08c84a3c2d634c92abbcf4bc3 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Thu, 8 Jul 2021 15:51:50 +0800 Subject: [PATCH 12/34] * Change variable name and add a todo for issueToZentaoObject. --- module/gitlab/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/gitlab/model.php b/module/gitlab/model.php index f4cba5b9c2..991f7621cc 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -1153,7 +1153,7 @@ class gitlabModel extends model list($gitlabField, $optionType, $options) = explode('|', $config); if(!isset($changes->$gitlabField) and $object->id != 0) continue; if($optionType == 'field') $value = $issue->$gitlabField; - if($optionType == 'field') $value = $issue->$gitlabField; + if($optionType == 'fields') $value = $issue->$gitlabField; // TODO(dingguodong) not implemented. if($options == 'date') $value = $value ? date('Y-m-d', strtotime($value)) : '0000-00-00'; if($options == 'datetime') $value = $value ? date('Y-m-d H:i:s', strtotime($value)) : '0000-00-00 00:00:00'; if($optionType == 'userPairs' and isset($issue->$gitlabField)) $value = zget($gitlabUsers, $issue->$gitlabField); From 47102c509e47f9dd36003f47f55a1bb376bf9e7e Mon Sep 17 00:00:00 2001 From: dingguodong Date: Thu, 8 Jul 2021 15:55:11 +0800 Subject: [PATCH 13/34] + Finished importing issue to story. --- module/gitlab/control.php | 3 ++- module/story/config.php | 2 +- module/story/model.php | 52 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 11a3aed968..076f7e86e8 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -285,6 +285,7 @@ class gitlab extends control $object = $this->gitlab->issueToZentaoObject($issue, $gitlabID); $object->product = $productList[$issueID]; $object->execution = $executionID; + if($objectType == 'task') { $objectID = $this->loadModel('task')->createTaskFromGitlabIssue($object, $executionID); @@ -302,7 +303,7 @@ class gitlab extends control if($objectID) { - $object->id = $objectID; + $object->id = $objectID; $this->gitlab->saveImportedIssue($gitlabID, $projectID, $objectType, $objectID, $issue, $object); } else diff --git a/module/story/config.php b/module/story/config.php index 5db4554810..985210da95 100644 --- a/module/story/config.php +++ b/module/story/config.php @@ -4,10 +4,10 @@ $config->story = new stdclass(); $config->story->batchCreate = 10; $config->story->affectedFixedNum = 7; $config->story->needReview = 1; +$config->story->removeFields = 'objectTypeList,productList,executionList,gitlabID,gitlabProjectID,execution'; $config->story->batchClose = new stdclass(); $config->story->batchClose->columns = 10; - $config->story->create = new stdclass(); $config->story->edit = new stdclass(); $config->story->change = new stdclass(); diff --git a/module/story/model.php b/module/story/model.php index 9e998cb7b8..5b69837f8f 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -216,7 +216,7 @@ class storyModel extends model /* Check repeat story. */ $result = $this->loadModel('common')->removeDuplicate('story', $story, "product={$story->product}"); - if($result['stop']) return array('status' => 'exists', 'id' => $result['duplicate']); + if(isset($result['stop']) and $result['stop']) return array('status' => 'exists', 'id' => $result['duplicate']); if($this->checkForceReview()) $story->status = 'draft'; if($story->status == 'draft') $story->stage = $this->post->plan > 0 ? 'planned' : 'wait'; @@ -348,6 +348,56 @@ class storyModel extends model return false; } + /** + * Create story from gitlab issue. + * + * @param object $story + * @param int $executionID + * @access public + * @return int + */ + public function createStoryFromGitlabIssue($story, $executionID) + { + foreach($story as $feild => $value) $_POST[$feild] = $value; + $now = helper::now(); + $story = fixer::input('post') + ->cleanInt('product,module,pri,plan') + ->callFunc('title', 'trim') + ->add('assignedDate', 0) + ->add('version', 1) + ->add('status', 'draft') + ->setDefault('plan,verify', '') + ->setDefault('openedBy', $this->app->user->account) + ->setDefault('openedDate', $now) + ->setIF($story->assignedTo != '', 'assignedDate', $now) + ->setIF($executionID > 0, 'status', 'active') + ->setIF($executionID > 0, 'stage', 'projected') + ->join('mailto', ',') + ->stripTags($this->config->story->editor->create['id'], $this->config->allowedTags) + ->remove('files,labels,reviewer,needNotReview,newStory,uid,contactListMenu,URS') + ->remove($this->config->story->removeFields) + ->get(); + + $requiredFields = $this->config->story->create->requiredFields; + $this->dao->insert(TABLE_STORY)->data($story, 'spec,verify,gitlab,gitlabProject')->autoCheck()->batchCheck($requiredFields, 'notempty')->exec(); + if(!dao::isError()) + { + $storyID = $this->dao->lastInsertID(); + + $data = new stdclass(); + $data->story = $storyID; + $data->version = 1; + $data->title = $story->title; + $data->spec = $story->spec; + $data->verify = $story->spec; + $this->dao->insert(TABLE_STORYSPEC)->data($data)->exec(); + + return $storyID; + } + + return false; + } + /** * Batch create stories. * From 22eeab384a4fd65609dfc496b71e67105baf7044 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Thu, 8 Jul 2021 16:07:58 +0800 Subject: [PATCH 14/34] * Change per_page value to 20. --- module/gitlab/model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 991f7621cc..d7fa2b393e 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -560,11 +560,11 @@ class gitlabModel extends model // TODO(dingguodong) not pagination yet. if($options) { - $url = sprintf($this->getApiRoot($gitlabID), "/projects/{$projectID}/issues") . '&per_page=100' . $options; + $url = sprintf($this->getApiRoot($gitlabID), "/projects/{$projectID}/issues") . '&per_page=20' . $options; } else { - $url = sprintf($this->getApiRoot($gitlabID), "/projects/{$projectID}/issues") . '&per_page=100'; + $url = sprintf($this->getApiRoot($gitlabID), "/projects/{$projectID}/issues") . '&per_page=20'; } return json_decode(commonModel::http($url)); } From 7bf0789e54ba969ad1aa1e83c6b7b2b680e2f150 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Thu, 8 Jul 2021 17:35:55 +0800 Subject: [PATCH 15/34] * Rename zt_jenkins to zt_pipeline. --- db/standard/zentao15.0.rc3.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/standard/zentao15.0.rc3.sql b/db/standard/zentao15.0.rc3.sql index d59660d05a..68b0271093 100644 --- a/db/standard/zentao15.0.rc3.sql +++ b/db/standard/zentao15.0.rc3.sql @@ -447,7 +447,7 @@ CREATE TABLE `zt_history` ( PRIMARY KEY (`id`), KEY `action` (`action`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -CREATE TABLE `zt_jenkins` ( +CREATE TABLE `zt_pipeline` ( `id` smallint(8) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `url` varchar(255) DEFAULT NULL, From 14d78cca44f711485dcb638ccfbe46f47114ef51 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Fri, 9 Jul 2021 10:15:04 +0800 Subject: [PATCH 16/34] * Construct object manually instead of using fixer. --- module/bug/model.php | 29 +++++------------------------ module/story/model.php | 25 ++++++------------------- module/task/model.php | 40 +++++++++------------------------------- 3 files changed, 20 insertions(+), 74 deletions(-) diff --git a/module/bug/model.php b/module/bug/model.php index d481824988..d5f0bf787b 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -283,30 +283,11 @@ class bugModel extends model */ public function createBugFromGitlabIssue($bug, $executionID) { - foreach($bug as $feild => $value) $_POST[$feild] = $value; - $now = helper::now(); - $bug = fixer::input('post') - ->setDefault('openedBy', $this->app->user->account) - ->setDefault('openedDate', $now) - ->setDefault('project,execution,story,task', 0) - ->setDefault('openedBuild', '1') // todo(dingguodong) openedBuild is hard-coded. - ->setDefault('deadline', '0000-00-00') - ->setIF($this->config->systemMode == 'new' && $this->lang->navGroup->bug != 'qa', 'project', $this->session->project) - ->setIF(strpos($this->config->bug->create->requiredFields, 'deadline') !== false, 'deadline', $bug->deadline) - ->setIF(isset($bug->assignedTo) and $bug->assignedTo != '', 'assignedDate', $now) - ->stripTags($this->config->bug->editor->create['id'], $this->config->allowedTags) - ->cleanInt('product,execution,module,severity') - ->join('openedBuild', ',') - ->join('mailto', ',') - ->remove('files, labels,uid,oldTaskID,contactListMenu') - ->remove($this->config->bug->removeFields) - ->get(); - - if($executionID != 0) - { - $bug->project = $this->dao->select('parent')->from(TABLE_EXECUTION)->where('id')->eq($executionID)->fetch('parent'); - $bug->execution = $executionID; - } + $bug->openedBy = $this->app->user->account; + $bug->openedBuild = 0; + $bug->story = 0; + $bug->task = 0; + $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()) diff --git a/module/story/model.php b/module/story/model.php index 5b69837f8f..ddba566108 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -358,25 +358,12 @@ class storyModel extends model */ public function createStoryFromGitlabIssue($story, $executionID) { - foreach($story as $feild => $value) $_POST[$feild] = $value; - $now = helper::now(); - $story = fixer::input('post') - ->cleanInt('product,module,pri,plan') - ->callFunc('title', 'trim') - ->add('assignedDate', 0) - ->add('version', 1) - ->add('status', 'draft') - ->setDefault('plan,verify', '') - ->setDefault('openedBy', $this->app->user->account) - ->setDefault('openedDate', $now) - ->setIF($story->assignedTo != '', 'assignedDate', $now) - ->setIF($executionID > 0, 'status', 'active') - ->setIF($executionID > 0, 'stage', 'projected') - ->join('mailto', ',') - ->stripTags($this->config->story->editor->create['id'], $this->config->allowedTags) - ->remove('files,labels,reviewer,needNotReview,newStory,uid,contactListMenu,URS') - ->remove($this->config->story->removeFields) - ->get(); + $story->status = 'active'; + $story->stage = 'projected'; + $story->openedBy = 'openedBy'; + $story->version = '1'; + + if(isset($story->execution)) unset($story->execution); $requiredFields = $this->config->story->create->requiredFields; $this->dao->insert(TABLE_STORY)->data($story, 'spec,verify,gitlab,gitlabProject')->autoCheck()->batchCheck($requiredFields, 'notempty')->exec(); diff --git a/module/task/model.php b/module/task/model.php index f01fba6664..6011759459 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -464,40 +464,18 @@ class taskModel extends model */ public function createTaskFromGitlabIssue($task, $executionID) { - foreach($task as $feild => $value) $_POST[$feild] = $value; - $requiredFields = ',' . $this->config->task->create->requiredFields . ','; - $requiredFields = trim($requiredFields, ','); - $task = fixer::input('post') - ->setDefault('execution', $executionID) - ->setDefault('estimate,left,story', 0) - ->setDefault('status', 'wait') - ->setIF($this->config->systemMode == 'new', 'project', $this->getProjectID($executionID)) - ->setIF($this->post->estimate != false, 'left', $this->post->estimate) - ->setIF($this->post->story != false, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story)) - ->setDefault('estStarted', '0000-00-00') - ->setDefault('deadline', '0000-00-00') - ->setIF(strpos($requiredFields, 'estStarted') !== false, 'estStarted', helper::isZeroDate($this->post->estStarted) ? '' : $this->post->estStarted) - ->setIF(strpos($requiredFields, 'deadline') !== false, 'deadline', helper::isZeroDate($this->post->deadline) ? '' : $this->post->deadline) - ->setIF(strpos($requiredFields, 'estimate') !== false, 'estimate', $this->post->estimate) - ->setIF(strpos($requiredFields, 'left') !== false, 'left', $this->post->left) - ->setIF(strpos($requiredFields, 'story') !== false, 'story', $this->post->story) - ->setIF(is_numeric($this->post->estimate), 'estimate', (float)$this->post->estimate) - ->setIF(is_numeric($this->post->consumed), 'consumed', (float)$this->post->consumed) - ->setIF(is_numeric($this->post->left), 'left', (float)$this->post->left) - ->setDefault('openedBy', $this->app->user->account) - ->setDefault('openedDate', helper::now()) - ->cleanINT('execution,story,module') - ->stripTags($this->config->task->editor->create['id'], $this->config->allowedTags) - ->join('mailto', ',') - ->remove('after,files,labels,assignedTo,uid,storyEstimate,storyDesc,storyPri,team,teamEstimate,teamMember,multiple,teams,contactListMenu,selectTestStory,testStory,testPri,testEstStarted,testDeadline,testAssignedTo,testEstimate,sync') - ->remove($this->config->task->removeFields) - ->add('version', 1) - ->get(); + $task->version = 1; + $task->openedBy = $this->app->user->account; + $task->story = 0; + $task->module = 0; + $task->estimate = 0; + $task->estStarted = '0000-00-00'; + + if(isset($task->product)) unset($task->product); $this->dao->insert(TABLE_TASK)->data($task, $skip = 'id') ->autoCheck() - ->batchCheck($requiredFields, 'notempty') - ->checkIF($task->estimate != '', 'estimate', 'float') + ->batchCheck($this->config->task->create->requiredFields, 'notempty') ->checkIF(!helper::isZeroDate($task->deadline), 'deadline', 'ge', $task->estStarted) ->exec(); From b062fe0a8e738d9cea78eb647744983ef20f23f4 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Fri, 9 Jul 2021 10:16:12 +0800 Subject: [PATCH 17/34] * Optimize codes when importing issues. --- module/gitlab/control.php | 3 ++- module/gitlab/lang/zh-cn.php | 11 ++++++----- module/gitlab/view/importissue.html.php | 8 ++++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 076f7e86e8..bde28ba333 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -327,7 +327,7 @@ class gitlab extends control ->fetchAll('issueID'); $iids = ''; foreach($savedIssueIDList as $savedIssueID) $iids = $iids . $savedIssueID->issueID . ','; - $options = '¬[iids]=' . trim($iids, ','); + $options = '&state=opened¬[iids]=' . trim($iids, ','); $gitlabIssues = $this->gitlab->apiGetIssues($gitlabID, $projectID, $options); //TODO(dingguodong) when no issues here? $products = array(); @@ -337,6 +337,7 @@ class gitlab extends control $products[$productID] = $this->loadModel("product")->getByID($productID)->name; } + $this->view->importable = empty($gitlabIssues) ? false : true; $this->view->products = $products; $this->view->gitlabID = $gitlabID; $this->view->gitlabProjectID = $projectID; diff --git a/module/gitlab/lang/zh-cn.php b/module/gitlab/lang/zh-cn.php index e2df334a72..09ac42e021 100644 --- a/module/gitlab/lang/zh-cn.php +++ b/module/gitlab/lang/zh-cn.php @@ -36,8 +36,9 @@ $lang->gitlab->placeholder->name = ''; $lang->gitlab->placeholder->url = "请填写Gitlab Server首页的访问地址,如:https://gitlab.zentao.net。"; $lang->gitlab->placeholder->token = "请填写具有admin权限账户的access token"; -$lang->gitlab->tokenError = "当前token非管理员权限。"; -$lang->gitlab->hostError = "无效的gitlab服务地址。"; -$lang->gitlab->bindUserError = "不能重复绑定用户 %s"; -$lang->gitlab->importIssueError = "未选择该议题所属的执行。"; -$lang->gitlab->importIssueWarn = "存在导入失败的议题,可再次尝试导入。"; +$lang->gitlab->noImportableIssues = "目前没有可供导入的议题。"; +$lang->gitlab->tokenError = "当前token非管理员权限。"; +$lang->gitlab->hostError = "无效的gitlab服务地址。"; +$lang->gitlab->bindUserError = "不能重复绑定用户 %s"; +$lang->gitlab->importIssueError = "未选择该议题所属的执行。"; +$lang->gitlab->importIssueWarn = "存在导入失败的议题,可再次尝试导入。"; diff --git a/module/gitlab/view/importissue.html.php b/module/gitlab/view/importissue.html.php index c43fcc2e24..98ca018d8f 100644 --- a/module/gitlab/view/importissue.html.php +++ b/module/gitlab/view/importissue.html.php @@ -15,6 +15,7 @@

gitlab->importIssue;?>

+
@@ -46,8 +47,11 @@ -
+
-
+ + + gitlab->noImportableIssues; ?> + From ab2e2191e3083c85a27baf51ef09bf81b77f243c Mon Sep 17 00:00:00 2001 From: dingguodong Date: Fri, 9 Jul 2021 13:48:23 +0800 Subject: [PATCH 18/34] * Bug fix and optimize for import issue. --- module/bug/model.php | 19 +++++++++---------- module/gitlab/control.php | 18 ++++-------------- module/gitlab/model.php | 2 ++ module/story/model.php | 9 +++++---- module/task/model.php | 24 ++++++++++++------------ 5 files changed, 32 insertions(+), 40 deletions(-) diff --git a/module/bug/model.php b/module/bug/model.php index d5f0bf787b..d51e28ce18 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -283,18 +283,16 @@ class bugModel extends model */ public function createBugFromGitlabIssue($bug, $executionID) { - $bug->openedBy = $this->app->user->account; - $bug->openedBuild = 0; - $bug->story = 0; - $bug->task = 0; - $bug->project = $this->dao->select('parent')->from(TABLE_EXECUTION)->where('id')->eq($executionID)->fetch('parent'); + $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->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()) - { - $bugID = $this->dao->lastInsertID(); - return $bugID; - } + if(!dao::isError()) return $this->dao->lastInsertID(); return false; } @@ -675,6 +673,7 @@ class bugModel extends model if(!empty($bug)) { $relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID); + $bug->id = $bugID; if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug); } return common::createChanges($oldBug, $bug); diff --git a/module/gitlab/control.php b/module/gitlab/control.php index bde28ba333..451a29d527 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -285,21 +285,11 @@ class gitlab extends control $object = $this->gitlab->issueToZentaoObject($issue, $gitlabID); $object->product = $productList[$issueID]; $object->execution = $executionID; + $clonedObject = clone $object; - if($objectType == 'task') - { - $objectID = $this->loadModel('task')->createTaskFromGitlabIssue($object, $executionID); - } - - if($objectType == 'bug') - { - $objectID = $this->loadModel('bug')->createBugFromGitlabIssue($object, $executionID); - } - - if($objectType == 'story') - { - $objectID = $this->loadModel('story')->createStoryFromGitlabIssue($object, $executionID); - } + if($objectType == 'task') $objectID = $this->loadModel('task')->createTaskFromGitlabIssue($clonedObject, $executionID); + if($objectType == 'bug') $objectID = $this->loadModel('bug')->createBugFromGitlabIssue($clonedObject, $executionID); + if($objectType == 'story') $objectID = $this->loadModel('story')->createStoryFromGitlabIssue($clonedObject, $executionID); if($objectID) { diff --git a/module/gitlab/model.php b/module/gitlab/model.php index d7fa2b393e..afa99f789e 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -1159,6 +1159,8 @@ class gitlabModel extends model if($optionType == 'userPairs' and isset($issue->$gitlabField)) $value = zget($gitlabUsers, $issue->$gitlabField); if($optionType == 'configItems' and isset($issue->$gitlabField)) $value = array_search($issue->$gitlabField, $this->config->gitlab->$options); if($value) $object->$zentaoField = $value; + + if($gitlabField == "description") $object->$zentaoField .= "
" . $issue->web_url; } return $object; } diff --git a/module/story/model.php b/module/story/model.php index ddba566108..f436d57f62 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -358,10 +358,11 @@ class storyModel extends model */ public function createStoryFromGitlabIssue($story, $executionID) { - $story->status = 'active'; - $story->stage = 'projected'; - $story->openedBy = 'openedBy'; - $story->version = '1'; + $story->status = 'active'; + $story->stage = 'projected'; + $story->openedBy = $this->app->user->account; + $story->version = 1; + $story->assignedDate = isset($story->assignedTo) ? helper::now() : 0; if(isset($story->execution)) unset($story->execution); diff --git a/module/task/model.php b/module/task/model.php index 6011759459..6fe25f81fa 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -464,25 +464,25 @@ class taskModel extends model */ public function createTaskFromGitlabIssue($task, $executionID) { - $task->version = 1; - $task->openedBy = $this->app->user->account; - $task->story = 0; - $task->module = 0; - $task->estimate = 0; - $task->estStarted = '0000-00-00'; + $task->version = 1; + $task->openedBy = $this->app->user->account; + $task->assignedDate = isset($task->assignedTo) ? helper::now() : 0; + $task->story = 0; + $task->module = 0; + $task->estimate = 0; + $task->estStarted = '0000-00-00'; + $task->left = 1; + $task->type = 'devel'; - if(isset($task->product)) unset($task->product); - - $this->dao->insert(TABLE_TASK)->data($task, $skip = 'id') + $this->dao->insert(TABLE_TASK)->data($task, $skip = 'id,product') ->autoCheck() ->batchCheck($this->config->task->create->requiredFields, 'notempty') ->checkIF(!helper::isZeroDate($task->deadline), 'deadline', 'ge', $task->estStarted) ->exec(); if(dao::isError()) return false; - - $taskID = $this->dao->lastInsertID(); - return $taskID; + + return $this->dao->lastInsertID(); } /** From d2a5588e9de35b41aa09ed29e1f8113d1501bfc4 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Fri, 9 Jul 2021 14:00:36 +0800 Subject: [PATCH 19/34] * Link story to execution. --- module/story/model.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/module/story/model.php b/module/story/model.php index f436d57f62..e987324b9b 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -379,6 +379,9 @@ class storyModel extends model $data->spec = $story->spec; $data->verify = $story->spec; $this->dao->insert(TABLE_STORYSPEC)->data($data)->exec(); + + /* Link story to execution. */ + $this->linkStory($executionID, $story->product, $storyID); return $storyID; } From 9e6b4db720a6dd50965cc7e8e92413ba9825a5d7 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Fri, 9 Jul 2021 14:33:49 +0800 Subject: [PATCH 20/34] * Fix bug when batch edit task,bug,story. --- module/bug/model.php | 7 +++++++ module/story/model.php | 5 +++++ module/task/model.php | 6 +++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/module/bug/model.php b/module/bug/model.php index d51e28ce18..b12997f76f 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -289,6 +289,8 @@ class bugModel extends model $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(); @@ -794,6 +796,11 @@ 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); + $bug->id = $bugID; + if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug); } else { diff --git a/module/story/model.php b/module/story/model.php index e987324b9b..a7a37c404a 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -694,6 +694,11 @@ class storyModel extends model } $this->file->updateObjectID($this->post->uid, $storyID, 'story'); + + /* update story to gitlab issue. */ + $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); + if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story); + return common::createChanges($oldStory, $story); } } diff --git a/module/task/model.php b/module/task/model.php index 6fe25f81fa..5d1eb2917f 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -978,7 +978,7 @@ class taskModel extends model ->batchCheckIF($task->closedReason == 'cancel', 'finishedBy, finishedDate', 'empty') ->where('id')->eq((int)$taskID)->exec(); - /* update story to gitlab issue. */ + /* update task to gitlab issue. */ $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); @@ -1281,6 +1281,10 @@ class taskModel extends model if($task->status == 'done') $this->loadModel('score')->create('task', 'finish', $taskID); if($task->status == 'closed') $this->loadModel('score')->create('task', 'close', $taskID); $allChanges[$taskID] = common::createChanges($oldTask, $task); + + /* update task to gitlab issue. */ + $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); + if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); } else { From 5de789ad8d383bc7882323142ec7b877a566d3b6 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Fri, 9 Jul 2021 15:03:18 +0800 Subject: [PATCH 21/34] * Fix bug when batch assign on task. --- module/task/model.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/module/task/model.php b/module/task/model.php index 5d1eb2917f..57b57da9f0 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -1371,8 +1371,10 @@ class taskModel extends model ->check('left', 'float') ->where('id')->eq($taskID)->exec(); + $task = $this->getById($taskID); + $task->id = $taskID; $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); - if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $oldTask); + if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); if(!dao::isError()) return common::createChanges($oldTask, $task); } From 677a3b00525d68362d08933806b369b6afbcb0f9 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Fri, 9 Jul 2021 17:22:27 +0800 Subject: [PATCH 22/34] * Add objectID to object for apiUpdateIssue(bug fix). --- module/gitlab/model.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/module/gitlab/model.php b/module/gitlab/model.php index afa99f789e..ff4437dab1 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -610,8 +610,9 @@ class gitlabModel extends model * @access public * @return object */ - public function apiUpdateIssue($gitlabID, $projectID, $issueID, $objectType, $object) + public function apiUpdateIssue($gitlabID, $projectID, $issueID, $objectType, $object, $objectID = null) { + if(!isset($object->id) && !empty($objectID)) $object->id = $objectID; $issue = $this->parseObjectToIssue($gitlabID, $projectID, $objectType, $object); $apiRoot = $this->getApiRoot($gitlabID); $url = sprintf($apiRoot, "/projects/{$projectID}/issues/{$issueID}"); @@ -1124,7 +1125,7 @@ class gitlabModel extends model /* Append this object link in zentao to gitlab issue description */ $zentaoLink = common::getSysURL() . helper::createLink($objectType, 'view', "id={$object->id}"); - $issue->description = $issue->description . "\n\n" . $zentaoLink; + if(strpos($issue->description, $zentaoLink) == false) $issue->description = $issue->description . "\n\n" . $zentaoLink; return $issue; } From fdb69a81b14d0ef6e328e80f0fb1bfa5a1c1d333 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Fri, 9 Jul 2021 17:23:16 +0800 Subject: [PATCH 23/34] * Change all lines about apiUpdateIssue func. --- module/bug/model.php | 21 ++++++++++----------- module/story/model.php | 18 +++++++++--------- module/task/control.php | 2 +- module/task/model.php | 15 +++++++-------- 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/module/bug/model.php b/module/bug/model.php index b12997f76f..b342d0eae7 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -675,8 +675,7 @@ class bugModel extends model if(!empty($bug)) { $relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID); - $bug->id = $bugID; - if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug); + if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID); } return common::createChanges($oldBug, $bug); } @@ -799,8 +798,7 @@ class bugModel extends model /* update bug to gitlab issue. */ $relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID); - $bug->id = $bugID; - if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug); + if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID); } else { @@ -858,7 +856,7 @@ class bugModel extends model 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); + if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', (Object)$bug, $bugID); } $oldBug = $bugs[$bugID]; @@ -896,11 +894,12 @@ class bugModel extends model ->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); + $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID); } if(!dao::isError()) return common::createChanges($oldBug, $bug); @@ -960,7 +959,7 @@ class bugModel extends model if(!empty($bug)) { $relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID); - if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug); + 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(); @@ -1055,7 +1054,7 @@ class bugModel extends model $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); + if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID); return common::createChanges($oldBug, $bug); } @@ -1188,7 +1187,7 @@ class bugModel extends model /* 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); + if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID); $changes[$bugID] = common::createChanges($oldBug, $bug); } @@ -1250,7 +1249,7 @@ class bugModel extends model if(!empty($bug)) { $relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID); - if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug); + if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID); } $bug->activatedCount += 1; @@ -1286,7 +1285,7 @@ class bugModel extends model 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($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID); } return common::createChanges($oldBug, $bug); } diff --git a/module/story/model.php b/module/story/model.php index a7a37c404a..e633e88daf 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -697,7 +697,7 @@ class storyModel extends model /* update story to gitlab issue. */ $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); - if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story); + if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID); return common::createChanges($oldStory, $story); } @@ -877,7 +877,7 @@ class storyModel extends model } /* update story to gitlab issue. */ $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); - if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story); + if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID); unset($oldStory->parent); unset($story->parent); @@ -1207,7 +1207,7 @@ class storyModel extends model /* update story to gitlab issue. */ $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); - if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story); + if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID); $this->executeHooks($storyID); if($story->type == 'story') $this->batchChangeStage(array($storyID), $story->stage); @@ -1481,7 +1481,7 @@ class storyModel extends model 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, 'story', $story); + if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID); } /* Update parent story status. */ @@ -1555,7 +1555,7 @@ class storyModel extends model 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, 'story', $story); + if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID); } } else @@ -1836,7 +1836,7 @@ class storyModel extends model { $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); $story->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $story->assignedTo); - if($story->assignee_id != '') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story); + if($story->assignee_id != '') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID); return common::createChanges($oldStory, $story); } return false; @@ -1871,11 +1871,11 @@ class storyModel extends model { $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); $story->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $story->assignedTo); - if($story->assignee_id != '') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story); + if($story->assignee_id != '') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID); /* Push this story to gitlab issue. */ $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); - if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story); + if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID); } } return $allChanges; @@ -1913,7 +1913,7 @@ class storyModel extends model /* Push this story to gitlab issue. */ $relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID); - if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story); + if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID); return common::createChanges($oldStory, $story); } diff --git a/module/task/control.php b/module/task/control.php index 64da0f0f6a..0c6540bbea 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -573,7 +573,7 @@ class task extends control $task = $this->task->getByID($taskID); $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); - $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); + $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID); $members = $this->loadModel('user')->getTeamMemberPairs($executionID, 'execution', 'nodeleted'); diff --git a/module/task/model.php b/module/task/model.php index 57b57da9f0..c01d508acd 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -980,7 +980,7 @@ class taskModel extends model /* update task to gitlab issue. */ $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); - if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); + if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID); if(!dao::isError()) { @@ -1284,7 +1284,7 @@ class taskModel extends model /* update task to gitlab issue. */ $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); - if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); + if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID); } else { @@ -1372,9 +1372,8 @@ class taskModel extends model ->where('id')->eq($taskID)->exec(); $task = $this->getById($taskID); - $task->id = $taskID; $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); - if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); + if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID); if(!dao::isError()) return common::createChanges($oldTask, $task); } @@ -1715,7 +1714,7 @@ class taskModel extends model 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, 'task', $task); + if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID); } if($oldTask->parent > 0) $this->updateParentStatus($taskID); @@ -1778,7 +1777,7 @@ class taskModel extends model 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', $task); + if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $task, $taskID); } if(!dao::isError()) @@ -1829,7 +1828,7 @@ class taskModel extends model 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, 'task', $task); + if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID); } if(!dao::isError()) return common::createChanges($oldTask, $task); @@ -1898,7 +1897,7 @@ class taskModel extends model if($oldTask->story) $this->loadModel('story')->setStage($oldTask->story); $relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID); - if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task); + if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID); if(!dao::isError()) return common::createChanges($oldTask, $task); } From d27efcb9eaec1e8a0f718169ea681139e9863306 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Fri, 9 Jul 2021 18:02:28 +0800 Subject: [PATCH 24/34] * Get full object when desc is empty. --- module/gitlab/model.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/module/gitlab/model.php b/module/gitlab/model.php index ff4437dab1..46415d56b0 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -612,6 +612,9 @@ class gitlabModel extends model */ public function apiUpdateIssue($gitlabID, $projectID, $issueID, $objectType, $object, $objectID = null) { + /* Get full object when desc is empty. */ + if(!isset($object->description) || (isset($object->description) && $object->description == '')) $object = $this->loadModel($objectType)->getByID($objectID); + if(!isset($object->id) && !empty($objectID)) $object->id = $objectID; $issue = $this->parseObjectToIssue($gitlabID, $projectID, $objectType, $object); $apiRoot = $this->getApiRoot($gitlabID); From 2fce8df996694fee18156b3983120ff8000ad899 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Mon, 12 Jul 2021 14:06:18 +0800 Subject: [PATCH 25/34] * Remove link when scm is not gitlab. --- module/repo/view/maintain.html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/repo/view/maintain.html.php b/module/repo/view/maintain.html.php index 4f754db09f..8c66203273 100644 --- a/module/repo/view/maintain.html.php +++ b/module/repo/view/maintain.html.php @@ -48,8 +48,8 @@ path; ?> id&objectID=$objectID", '', 'list', 'edit'); - common::printIcon('gitlab', 'importissue', "repo={$repo->id}", '', 'list', 'link'); + common::printIcon('repo', 'edit', "repoID=$repo->id&objectID=$objectID", '', 'list', 'edit'); + if(strtolower($repo->SCM) == "gitlab") common::printIcon('gitlab', 'importissue', "repo={$repo->id}", '', 'list', 'link'); // disable button instead of hiding it. if(common::hasPriv('repo', 'delete')) echo html::a($this->createLink('repo', 'delete', "repoID=$repo->id&objectID=$objectID"), '', 'hiddenwin', "title='{$lang->repo->delete}' class='btn'"); ?> From cc60268ee4721096d6d7ac35ee5688f18fd5dbff Mon Sep 17 00:00:00 2001 From: dingguodong Date: Mon, 12 Jul 2021 14:32:48 +0800 Subject: [PATCH 26/34] * Filter issue in gitlab using alternative way. --- module/gitlab/control.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 451a29d527..c0af485b49 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -315,10 +315,20 @@ class gitlab extends control ->where('relation')->eq('gitlab') ->andWhere('product')->in($productIDList) ->fetchAll('issueID'); - $iids = ''; - foreach($savedIssueIDList as $savedIssueID) $iids = $iids . $savedIssueID->issueID . ','; - $options = '&state=opened¬[iids]=' . trim($iids, ','); - $gitlabIssues = $this->gitlab->apiGetIssues($gitlabID, $projectID, $options); //TODO(dingguodong) when no issues here? + + /* 'not[iids]' option in gitlab API has a issue when iids is too long. */ + $gitlabIssues = $this->gitlab->apiGetIssues($gitlabID, $projectID, '&state=opened'); + foreach($gitlabIssues as $index => $issue) + { + foreach($savedIssueIDList as $savedIssueID) + { + if($issue->iid == $savedIssueID->issueID) + { + unset($gitlabIssues[$index]); + break; + } + } + } $products = array(); $products[] = ''; From 9ae5f3e8fe5727979426a68a77111c543afcf27f Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 13 Jul 2021 10:02:06 +0800 Subject: [PATCH 27/34] * Change getting repoID from _GET to getting from para. --- module/gitlab/control.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/module/gitlab/control.php b/module/gitlab/control.php index c0af485b49..28540a6fe2 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -254,12 +254,13 @@ class gitlab extends control /** * Import gitlab issue to zentaopms. * + * @param int $repoID * @access public * @return void */ - public function importIssue() + public function importIssue($repoID) { - $repo = $this->loadModel('repo')->getRepoByID($this->get->repo); + $repo = $this->loadModel('repo')->getRepoByID($repoID); $productIDList = explode(',', $repo->product); $gitlabID = $repo->gitlab; $projectID = $repo->project; From 1d0f19caaa128b6225b470a0bc2feca30a513592 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 13 Jul 2021 11:06:13 +0800 Subject: [PATCH 28/34] + Delete project relation when user deleting a repo. --- module/gitlab/model.php | 31 +++++++++++++++++++++++++++++++ module/repo/control.php | 3 +++ 2 files changed, 34 insertions(+) diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 46415d56b0..0a22c5f143 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -863,6 +863,37 @@ class gitlabModel extends model return true; } + /** + * Delete project relation. + * + * condition: when user deleting a repo. + * + * @param int $repoID + * @access public + * @return void + */ + public function deleteProjectRelation($repoID) + { + $repo = $this->dao->select('product,path as gitlabProjectID,client as gitlabID')->from(TABLE_REPO) + ->where('id')->eq($repoID) + ->andWhere('deleted')->eq(0) + ->fetch(); + if(empty($repo)) return false; + + $productIDList = explode(',', $repo->product); + foreach($productIDList as $product) + { + $this->dao->delete()->from(TABLE_RELATION) + ->where('product')->eq($product) + ->andWhere('AType')->eq('gitlab') + ->andWhere('BType')->eq('gitlabProject') + ->andWhere('relation')->eq('interrated') + ->andWhere('AID')->eq($repo->gitlabID) + ->andWhere('BID')->eq($repo->gitlabProjectID) + ->exec(); + } + } + /** * Create webhook for zentao. * diff --git a/module/repo/control.php b/module/repo/control.php index c16b3c61cb..c12c786b4e 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -209,6 +209,9 @@ class repo extends control die(js::confirm($this->lang->repo->notice->delete, $this->repo->createLink('delete', "repoID=$repoID&objectID=$objectID&confirm=yes"))); } + /* Delete project relation for gitlab type. */ + $this->loadModel('gitlab')->deleteProjectRelation($repoID); + $relationID = $this->dao->select('id')->from(TABLE_RELATION)->where('extra')->eq($repoID)->fetch(); if($relationID) { From fef177344ed5d6863e10b72a420d435dd3786e05 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 13 Jul 2021 11:08:24 +0800 Subject: [PATCH 29/34] * Rename gitlab issue name to en lang. --- module/gitlab/lang/zh-cn.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/module/gitlab/lang/zh-cn.php b/module/gitlab/lang/zh-cn.php index 09ac42e021..923bcf7baf 100644 --- a/module/gitlab/lang/zh-cn.php +++ b/module/gitlab/lang/zh-cn.php @@ -6,7 +6,7 @@ $lang->gitlab->create = '添加gitlab'; $lang->gitlab->edit = '编辑gitlab'; $lang->gitlab->bindUser = '绑定用户'; $lang->gitlab->bindProduct = '关联产品'; -$lang->gitlab->importIssue = '关联议题'; +$lang->gitlab->importIssue = '关联issue'; $lang->gitlab->delete = '删除'; $lang->gitlab->confirmDelete = '确认删除该gitlab吗?'; $lang->gitlab->gitlabAccount = 'gitlab用户'; @@ -15,7 +15,7 @@ $lang->gitlab->zentaoAccount = '禅道用户'; $lang->gitlab->browseAction = 'gitlab列表'; $lang->gitlab->deleteAction = '删除gitlab'; $lang->gitlab->gitlabProject = "{$lang->gitlab->common}项目"; -$lang->gitlab->gitlabIssue = "{$lang->gitlab->common}议题"; +$lang->gitlab->gitlabIssue = "{$lang->gitlab->common}issue"; $lang->gitlab->zentaoProduct = '禅道产品'; $lang->gitlab->objectType = '类型'; // task, bug, story @@ -36,9 +36,9 @@ $lang->gitlab->placeholder->name = ''; $lang->gitlab->placeholder->url = "请填写Gitlab Server首页的访问地址,如:https://gitlab.zentao.net。"; $lang->gitlab->placeholder->token = "请填写具有admin权限账户的access token"; -$lang->gitlab->noImportableIssues = "目前没有可供导入的议题。"; +$lang->gitlab->noImportableIssues = "目前没有可供导入的issue。"; $lang->gitlab->tokenError = "当前token非管理员权限。"; $lang->gitlab->hostError = "无效的gitlab服务地址。"; $lang->gitlab->bindUserError = "不能重复绑定用户 %s"; -$lang->gitlab->importIssueError = "未选择该议题所属的执行。"; -$lang->gitlab->importIssueWarn = "存在导入失败的议题,可再次尝试导入。"; +$lang->gitlab->importIssueError = "未选择该issue所属的执行。"; +$lang->gitlab->importIssueWarn = "存在导入失败的issue,可再次尝试导入。"; From b3641df7b20438e11bbe1c3f3e799f90199d9b3a Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 13 Jul 2021 14:36:01 +0800 Subject: [PATCH 30/34] * Display icon name in lang setting. --- module/gitlab/view/browse.html.php | 2 +- module/repo/view/maintain.html.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/module/gitlab/view/browse.html.php b/module/gitlab/view/browse.html.php index 1fc24f76e0..dd3311b1dd 100644 --- a/module/gitlab/view/browse.html.php +++ b/module/gitlab/view/browse.html.php @@ -37,7 +37,7 @@ createLink('gitlab', 'delete', "gitlabID=$id"), '', 'hiddenwin', "title='{$lang->gitlab->delete}' class='btn'"); ?> diff --git a/module/repo/view/maintain.html.php b/module/repo/view/maintain.html.php index 8c66203273..cd358fb3ce 100644 --- a/module/repo/view/maintain.html.php +++ b/module/repo/view/maintain.html.php @@ -49,7 +49,7 @@ id&objectID=$objectID", '', 'list', 'edit'); - if(strtolower($repo->SCM) == "gitlab") common::printIcon('gitlab', 'importissue', "repo={$repo->id}", '', 'list', 'link'); // disable button instead of hiding it. + if(strtolower($repo->SCM) == "gitlab") common::printIcon('gitlab', 'importIssue', "repo={$repo->id}", '', 'list', 'link'); // disable button instead of hiding it. if(common::hasPriv('repo', 'delete')) echo html::a($this->createLink('repo', 'delete', "repoID=$repo->id&objectID=$objectID"), '', 'hiddenwin', "title='{$lang->repo->delete}' class='btn'"); ?> From c8b3045fc9768ba8808358e5cf591258735c82f6 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 13 Jul 2021 14:39:20 +0800 Subject: [PATCH 31/34] * Rename pipline to pipeline. --- db/zentao.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/zentao.sql b/db/zentao.sql index 7146cad404..d0e6ffda1e 100644 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -471,8 +471,8 @@ CREATE TABLE IF NOT EXISTS `zt_history` ( PRIMARY KEY (`id`), KEY `action` (`action`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- DROP TABLE IF EXISTS `zt_pipline`; -CREATE TABLE IF NOT EXISTS `zt_pipline` ( +-- DROP TABLE IF EXISTS `zt_pipeline`; +CREATE TABLE IF NOT EXISTS `zt_pipeline` ( `id` smallint(8) unsigned NOT NULL AUTO_INCREMENT, `type` char(30) NOT NULL, `name` varchar(50) NOT NULL, From dd7d97fc044d2c97f6ae3068677024b4f52aaf6f Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 13 Jul 2021 15:00:58 +0800 Subject: [PATCH 32/34] * Add private column to sql file. --- db/zentao.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/zentao.sql b/db/zentao.sql index d0e6ffda1e..c62ac037f9 100644 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -480,6 +480,7 @@ CREATE TABLE IF NOT EXISTS `zt_pipeline` ( `account` varchar(30) DEFAULT NULL, `password` varchar(255) NOT NULL, `token` varchar(255) DEFAULT NULL, + `private` char(32) DEFAULT NULL, `createdBy` varchar(30) NOT NULL, `createdDate` datetime NOT NULL, `editedBy` varchar(30) NOT NULL, From fee5d53f946957c81b887d128959d449ab988c43 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 13 Jul 2021 16:50:46 +0800 Subject: [PATCH 33/34] * Optimize import issue and bug fix. --- module/gitlab/control.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 28540a6fe2..b8b72c1201 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -314,7 +314,9 @@ class gitlab extends control $savedIssueIDList = $this->dao->select('BID as issueID')->from(TABLE_RELATION) ->where('relation')->eq('gitlab') - ->andWhere('product')->in($productIDList) + ->andWhere('BType')->eq('issue') + ->andWhere('BVersion')->eq($projectID) + ->andWhere('extra')->eq($gitlabID) ->fetchAll('issueID'); /* 'not[iids]' option in gitlab API has a issue when iids is too long. */ From a519be7fb673f3f8e3f70447ffc2313a3ea2a1a7 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 13 Jul 2021 17:43:59 +0800 Subject: [PATCH 34/34] * Bug fix when assign user on story in execution. --- module/gitlab/model.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 0a22c5f143..a153b99b58 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -612,9 +612,14 @@ class gitlabModel extends model */ public function apiUpdateIssue($gitlabID, $projectID, $issueID, $objectType, $object, $objectID = null) { + $oldObject = clone $object; /* Get full object when desc is empty. */ if(!isset($object->description) || (isset($object->description) && $object->description == '')) $object = $this->loadModel($objectType)->getByID($objectID); - + foreach($oldObject as $index => $attribute) + { + if($index != 'description') $object->$index = $attribute; + } + if(!isset($object->id) && !empty($objectID)) $object->id = $objectID; $issue = $this->parseObjectToIssue($gitlabID, $projectID, $objectType, $object); $apiRoot = $this->getApiRoot($gitlabID);