From 4dd58196d77bff4e4525828101c5cabe30f55b74 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Mon, 2 Aug 2021 16:02:10 +0800 Subject: [PATCH] * adjust for upgrade. --- module/upgrade/model.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 3a0a7758e3..59e75c9b32 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -688,6 +688,11 @@ class upgradeModel extends model $this->saveLogs('Execute 15_0_3'); $this->execSQL($this->getUpgradeFile('15.0.3')); $this->appendExec('15_0_3'); + case '15_2': + $this->saveLogs('Execute 15_2'); + $this->execSQL($this->getUpgradeFile('15.2')); + $this->processGitlabRepo(); + $this->appendExec('15_2'); } $this->deletePatch(); @@ -5121,31 +5126,27 @@ class upgradeModel extends model * Process gitlab repo data. * * @access public - * @return void + * @return bool */ public function processGitlabRepo() { $repoList = $this->dao->select('*')->from(TABLE_REPO)->where('SCM')->eq('Gitlab')->fetchAll(); foreach($repoList as $repo) { + if(is_numeric($repo->path)) continue; + /* Create gitlab from repo. */ $gitlab = new stdclass; $gitlab->type = 'gitlab'; $gitlab->name = $repo->client; - $gitlab->token = base64_decode($repo->password); + $gitlab->url = $repo->client; + $gitlab->token = $repo->encrypt == 'base64' ? base64_decode($repo->password) : $repo->password; $gitlab->private = md5(uniqid()); $this->dao->insert(TABLE_PIPELINE)->data($gitlab)->exec(); $gitlabID = $this->dao->lastInsertID(); - - preg_match('/projects\/(\d+)\/repository/', $repo->path, $matches); - $gitlabProject = $matches[1]; - $products = explode(',', $repo->product); - $this->loadModel('gitlab')->saveProjectRelation($products, $gitlabID, $gitlabProject); - - $this->dao->update(TABLE_REPO)->set('client')->eq($gitlabID)->set('path')->eq($gitlabProject)->where('id')->eq($repo->id)->exec(); - - $this->loadModel("gitlab")->initWebhooks($products, $gitlabID, $gitlabProject); + $this->dao->update(TABLE_REPO)->set('client')->eq($gitlabID)->set('path')->eq($repo->extra)->where('id')->eq($repo->id)->exec(); } + return true; } }