From e80d9acf3735d0c2be0a3254c73f5c8e54259f03 Mon Sep 17 00:00:00 2001 From: liyuchun Date: Thu, 25 Nov 2021 14:51:11 +0800 Subject: [PATCH] * Finish task #44796. --- module/job/control.php | 4 ++-- module/job/js/create.js | 2 +- module/repo/model.php | 14 +++++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/module/job/control.php b/module/job/control.php index a79c74f3e9..df4cf40563 100644 --- a/module/job/control.php +++ b/module/job/control.php @@ -369,8 +369,8 @@ class job extends control public function ajaxGetRefList($repoID) { $repo = $this->loadModel('repo')->getRepoByID($repoID); - if($repo->SCM != 'Gitlab') $this->send(array('result' => 'fail')); - $refList = $this->loadModel('gitlab')->getReferenceOptions($repo->gitlab, $repo->project); + if($repo->SCM == 'Gitlab') $refList = $this->loadModel('gitlab')->getReferenceOptions($repo->gitlab, $repo->project); + if($repo->SCM != 'Gitlab') $refList = $this->repo->getBranches($repo, true); $this->send(array('result' => 'success', 'refList' => $refList)); } diff --git a/module/job/js/create.js b/module/job/js/create.js index 50e4d912dc..635ce8abc2 100644 --- a/module/job/js/create.js +++ b/module/job/js/create.js @@ -22,7 +22,7 @@ $(document).ready(function() { if(data.result == 'success') { - if(data.type == 'gitlab') + if(data.type.indexOf('git') != -1) { $('.reference').show(); $('.svn-fields').addClass('hidden'); diff --git a/module/repo/model.php b/module/repo/model.php index 184c9eb814..5c2c5cb3c7 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -416,15 +416,23 @@ class repoModel extends model /** * Get git branches. * - * @param object $repo + * @param object $repo + * @param bool $printLabel * @access public * @return array */ - public function getBranches($repo) + public function getBranches($repo, $printLabel = false) { $this->scm = $this->app->loadClass('scm'); $this->scm->setEngine($repo); - return $this->scm->branch(); + $branches = $this->scm->branch(); + + if($printLabel) + { + foreach($branches as &$branch) $branch = 'Branch::' . $branch; + } + + return $branches; } /**