This commit is contained in:
lichengjun
2021-07-01 16:22:07 +08:00
9 changed files with 26 additions and 22 deletions
+1 -1
View File
@@ -1552,7 +1552,7 @@ class bug extends control
else
{
/* Delete related issue in gitlab. */
$relation = $this->loadModel('gitlab')->getGitlabIssueFromRelation('bug', $bugID);
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
if(!empty($relation)) $this->loadModel('gitlab')->deleteIssue($relation->gitlabID, $relation->projectID, 'bug', $bugID, $relation->issueID);
$this->bug->delete(TABLE_BUG, $bugID);
+2 -2
View File
@@ -856,7 +856,7 @@ class bugModel extends model
->autoCheck()
->where('id')->eq($bugID)->exec();
$relation = $this->loadModel('gitlab')->getGitlabIssueFromRelation('bug', $bugID);
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
$attribute = new stdclass();
$attribute->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $bug->assignedTo);
if($attribute->assignee_id != '')
@@ -1226,7 +1226,7 @@ class bugModel extends model
->remove('comment')
->get();
$relation = $this->loadModel('gitlab')->getGitlabIssueFromRelation('bug', $bugID);
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
$singleIssue = new stdclass();
$singleIssue = $this->loadModel('gitlab')->apiSingleIssue($relation->gitlabID, $relation->issueID);
+15 -11
View File
@@ -27,10 +27,10 @@ class gitlab extends control
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
$this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->browse;
$this->view->position[] = $this->lang->gitlab->common;
$this->view->position[] = $this->lang->gitlab->browse;
$this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->browse;
$this->view->gitlabList = $this->gitlab->getList($orderBy, $pager);
$this->view->orderBy = $orderBy;
$this->view->pager = $pager;
@@ -118,12 +118,8 @@ class gitlab extends control
$user->providerID = $gitlabID;
$user->providerType = 'gitlab';
$this->dao->delete()
->from(TABLE_OAUTH)
->where('providerType')->eq($user->providerType)
->andWhere('providerID')->eq($user->providerID)
->exec();
/* Delete binded users and save new relationship.*/
$this->dao->delete()->from(TABLE_OAUTH)->where('providerType')->eq($user->providerType)->andWhere('providerID')->eq($user->providerID)->exec();
foreach($users as $openID => $account)
{
if(!$account) continue;
@@ -212,8 +208,7 @@ class gitlab extends control
$gitlab = $this->get->gitlab;
$project = $this->get->project;
$input = '{"object_kind":"issue","event_type":"issue","user":{"id":1,"name":"Administrator","username":"root","avatar_url":"https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon","email":"admin@example.com"},"project":{"id":36,"name":"zenops202106dgd","description":"repo for dingguodong dev env","web_url":"http://192.168.1.161:51080/root/zenops202106dgd","avatar_url":null,"git_ssh_url":"ssh://git@192.168.1.161:51022/root/zenops202106dgd.git","git_http_url":"http://192.168.1.161:51080/root/zenops202106dgd.git","namespace":"Administrator","visibility_level":0,"path_with_namespace":"root/zenops202106dgd","default_branch":"master","ci_config_path":null,"homepage":"http://192.168.1.161:51080/root/zenops202106dgd","url":"ssh://git@192.168.1.161:51022/root/zenops202106dgd.git","ssh_url":"ssh://git@192.168.1.161:51022/root/zenops202106dgd.git","http_url":"http://192.168.1.161:51080/root/zenops202106dgd.git"},"object_attributes":{"author_id":1,"closed_at":null,"confidential":false,"created_at":"2021-06-22 02:38:01 UTC","description":"扩展动作的公式保存之后再点设置按钮报js错误\nnew issue 0622 desc ee\n![elephant](http://192.168.1.161:51080/root/zenops202106dgd/uploads/9b85fd397a602b628a271ce02264f502/elephant.jpg)","discussion_locked":null,"due_date":"2021-06-25","id":33,"iid":3,"last_edited_at":"2021-06-24 02:53:52 UTC","last_edited_by_id":1,"milestone_id":null,"moved_to_id":null,"duplicated_to_id":null,"project_id":36,"relative_position":1539,"state_id":1,"time_estimate":0,"title":"new issue 0622","updated_at":"2021-06-24 02:53:52 UTC","updated_by_id":1,"url":"http://192.168.1.161:51080/root/zenops202106dgd/-/issues/3","total_time_spent":0,"human_total_time_spent":null,"human_time_estimate":null,"assignee_ids":[8],"assignee_id":8,"labels":[{"id":38,"title":"zentao_objectType","color":"#0033CC","project_id":36,"created_at":"2021-06-16 12:04:23 UTC","updated_at":"2021-06-22 05:17:29 UTC","template":false,"description":"task","type":"ProjectLabel","group_id":null},{"id":40,"title":"zentao_task/12738","color":"#428BCA","project_id":36,"created_at":"2021-06-21 08:58:17 UTC","updated_at":"2021-06-24 02:46:14 UTC","template":false,"description":"type:bug,id:1234,url:https://back.zcorp.cc/pms/project-browse-1291-all.html","type":"ProjectLabel","group_id":null}],"state":"opened","action":"update"},"labels":[{"id":38,"title":"zentao_objectType","color":"#0033CC","project_id":36,"created_at":"2021-06-16 12:04:23 UTC","updated_at":"2021-06-22 05:17:29 UTC","template":false,"description":"task","type":"ProjectLabel","group_id":null},{"id":40,"title":"zentao_task/12738","color":"#428BCA","project_id":36,"created_at":"2021-06-21 08:58:17 UTC","updated_at":"2021-06-24 02:46:14 UTC","template":false,"description":"type:bug,id:1234,url:https://back.zcorp.cc/pms/project-browse-1291-all.html","type":"ProjectLabel","group_id":null}],"changes":{},"repository":{"name":"zenops202106dgd","url":"ssh://git@192.168.1.161:51022/root/zenops202106dgd.git","description":"repo for dingguodong dev env","homepage":"http://192.168.1.161:51080/root/zenops202106dgd"},"assignees":[{"id":8,"name":"dingguodong","username":"dingguodong","avatar_url":"https://www.gravatar.com/avatar/11302c6dd9e26e9f8e4517538f51e4a2?s=80\u0026d=identicon","email":"dingguodong@easycorp.ltd"}]}';
//$input = file_get_contents('php://input');
$input = file_get_contents('php://input');
$requestBody = json_decode($input);
$result = $this->gitlab->webhookParseBody($requestBody, $gitlab);
@@ -225,11 +220,17 @@ class gitlab extends control
{
fwrite($fh, date('Ymd H:i:s') . ": " . $this->app->getURI() . "\n");
fwrite($fh, "JSON: \n " . $input . "\n");
fwrite($fh, "Parsed object: {$result->objectType} :\n " . print_r($result->object, true) . "\n");
fwrite($fh, "Parsed object: {$result->issue->objectType} :\n " . print_r($result->object, true) . "\n");
fclose($fh);
}
if($result->action = 'updateissue') $this->gitlab->webhookSyncIssue($gitlab, $result);
if($result->action == 'updateissue' and isset($result->changes->assignees)) $this->gitlab->webhookAssignIssue($result);
//if($result->action = 'reopenissue') $this->gitlab->webhookIssueReopen($gitlab, $result);
if($result->action == 'closeissue') $this->gitlab->webhookCloseIssue($result);
if($result->action == 'updateissue') $this->gitlab->webhookSyncIssue($gitlab, $result);
$this->view->result = 'success';
$this->view->status = 'ok';
@@ -241,6 +242,9 @@ class gitlab extends control
{
$gitlabID = 1; $projectID = 7;
$task = $this->loadModel('task')->getByID($id);
$relations = $this->gitlab->getRelationByObject('task', $task->id);
a($relations);exit;
$issue = $this->gitlab->taskToIssue($gitlabID, $projectID, $task);
$issue = $this->gitlab->apiCreateIssue($gitlabID, $projectID, $issue);
$this->gitlab->saveSyncedIssue('task', $task, $gitlabID, $issue);
+2 -2
View File
@@ -209,7 +209,7 @@ class gitlabModel extends model
*/
public function getRelationByObject($objectType, $objectID)
{
return $this->dao->select('*, id, extra as gitlabID, BVersion as projectID, BID as issueID')->from(TABLE_RELATION)
return $this->dao->select('*, extra as gitlabID, BVersion as projectID, BID as issueID')->from(TABLE_RELATION)
->where('relation')->eq('gitlab')
->andWhere('Atype')->eq($objectType)
->andWhere('AID')->eq($objectID)
@@ -775,7 +775,7 @@ class gitlabModel extends model
* @access public
* @return void
*/
public function saveRelation($products, $gitlabID, $gitlabProjectID)
public function saveProjectRelation($products, $gitlabID, $gitlabProjectID)
{
$programs = $this->dao->select('id,program')->from(TABLE_PRODUCT)->where('id')->in($products)->fetchPairs();
+2 -2
View File
@@ -232,7 +232,7 @@ class repoModel extends model
if($this->post->SCM == 'Gitlab')
{
$this->loadModel("gitlab")->saveRelation($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
$this->loadModel("gitlab")->saveProjectRelation($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
/* create webhook for zentao */
$this->loadModel("gitlab")->createWebhook($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
@@ -293,7 +293,7 @@ class repoModel extends model
$this->rmClientVersionFile();
if($repo->SCM == 'Gitlab') $this->loadModel("gitlab")->saveRelation($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
if($repo->SCM == 'Gitlab') $this->loadModel("gitlab")->saveProjectRelation($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
if($repo->path != $data->path)
{
$this->dao->delete()->from(TABLE_REPOHISTORY)->where('repo')->eq($id)->exec();
+1 -1
View File
@@ -988,7 +988,7 @@ class story extends control
else
{
/* Delete related issue in gitlab. */
$relation = $this->loadModel('gitlab')->getGitlabIssueFromRelation('story', $storyID);
$relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID);
$this->loadModel('gitlab')->deleteIssue($relation->gitlabID, $relation->projectID, 'story', $storyID, $relation->issueID);
$this->story->delete(TABLE_STORY, $storyID);
+1 -1
View File
@@ -1772,7 +1772,7 @@ class storyModel extends model
if(!dao::isError())
{
$relation = $this->loadModel('gitlab')->getGitlabIssueFromRelation('story', $storyID);
$relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID);
$attribute = new stdclass();
$attribute->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $story->assignedTo);
if($attribute->assignee_id != '')
+1 -1
View File
@@ -1281,7 +1281,7 @@ class task extends control
else
{
/* Delete related issue in gitlab. */
$relation = $this->loadModel('gitlab')->getGitlabIssueFromRelation('task', $taskID);
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
$this->loadModel('gitlab')->deleteIssue($relation->gitlabID, $relation->projectID, 'task', $taskID, $relation->issueID);
$this->task->delete(TABLE_TASK, $taskID);
+1 -1
View File
@@ -1330,7 +1330,7 @@ class taskModel extends model
->check('left', 'float')
->where('id')->eq($taskID)->exec();
$relation = $this->loadModel('gitlab')->getGitlabIssueFromRelation('task', $taskID);
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
$attribute = new stdclass();
$attribute->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $task->assignedTo);
if($attribute->assignee_id != '')