From 35a2251dcb19dd40bbd04389217a6c77442ebd1c Mon Sep 17 00:00:00 2001 From: wangyidong Date: Mon, 9 Mar 2020 14:13:16 +0800 Subject: [PATCH] * adjust for get svnDir. --- lib/scm/subversion.class.php | 5 +++-- module/jenkins/config.php | 4 ++-- module/job/css/create.css | 2 +- module/job/css/edit.css | 2 +- module/job/js/create.js | 3 ++- module/job/js/edit.js | 3 ++- module/job/view/create.html.php | 2 +- module/job/view/edit.html.php | 3 +-- module/svn/model.php | 37 +++------------------------------ 9 files changed, 16 insertions(+), 45 deletions(-) diff --git a/lib/scm/subversion.class.php b/lib/scm/subversion.class.php index 9ae31fd1f6..02e80e8efa 100644 --- a/lib/scm/subversion.class.php +++ b/lib/scm/subversion.class.php @@ -104,13 +104,14 @@ class Subversion } ksort($dirs); - $tags = array(); + $tags = array(); + $prefix = empty(trim($path, '/')) ? '/' : '/' . trim($path, '/') . '/'; foreach($dirs as $dirNames) { ksort($dirNames); foreach($dirNames as $dirName) { - $dirPath = $path . '/' . $dirName; + $dirPath = $prefix . $dirName; $tags[$dirPath] = $dirName; } } diff --git a/module/jenkins/config.php b/module/jenkins/config.php index 47c1f211d4..874d71aea1 100644 --- a/module/jenkins/config.php +++ b/module/jenkins/config.php @@ -1,5 +1,5 @@ jenkins->create = new stdclass(); $config->jenkins->edit = new stdclass(); -$config->jenkins->create->requiredFields = 'name,url,credentials'; -$config->jenkins->edit->requiredFields = 'name,url,credentials'; +$config->jenkins->create->requiredFields = 'name,url'; +$config->jenkins->edit->requiredFields = 'name,url'; diff --git a/module/job/css/create.css b/module/job/css/create.css index fb133566f6..d0fd86e9f7 100644 --- a/module/job/css/create.css +++ b/module/job/css/create.css @@ -4,4 +4,4 @@ .checkbox-primary.checkbox-inline label{padding-left:5px !important;} #jkHost_chosen .chosen-single{border-right:0px;} #jkJobBox{width:385px;} -#svnDirBox .input-group .chosen-single{min-width:200px;} +#svnDirBox .input-group{width:unset !important} diff --git a/module/job/css/edit.css b/module/job/css/edit.css index b1790c3e28..18378d434c 100644 --- a/module/job/css/edit.css +++ b/module/job/css/edit.css @@ -4,4 +4,4 @@ .checkbox-primary.checkbox-inline label{padding-left:5px !important;} #jkHost_chosen .chosen-single{border-right:0px;} #jkJobBox{width:385px;} -#svnDirBox .input-group .chosen-single{min-width:200px;} +#svnDirBox .input-group{width:unset !important} diff --git a/module/job/js/create.js b/module/job/js/create.js index 1ccf2640e6..79b2634818 100644 --- a/module/job/js/create.js +++ b/module/job/js/create.js @@ -29,7 +29,7 @@ $('#repo').change(function() } }) -$(document).on('change', '#svnDir', function() +$(document).on('change', '[name^=svnDir]', function() { var repoID = $('#repo').val(); var selectedTag = $(this).val(); @@ -61,6 +61,7 @@ $(document).on('change', '#svnDir', function() $('#svnDirBox .loading').remove(); $('#svnDirBox .input-group').append(html); $('#svnDirBox #svnDir' + length).chosen(); + $('#svnDir' + length + '_chosen .chosen-single').css('border-left', '0px'); }) }) diff --git a/module/job/js/edit.js b/module/job/js/edit.js index 2b1c803c09..39eb2c1558 100644 --- a/module/job/js/edit.js +++ b/module/job/js/edit.js @@ -29,7 +29,7 @@ $('#repo').change(function() } }) -$(document).on('change', '#svnDir', function() +$(document).on('change', '[name^=svnDir]', function() { var repoID = $('#repo').val(); var selectedTag = $(this).val(); @@ -61,6 +61,7 @@ $(document).on('change', '#svnDir', function() $('#svnDirBox .loading').remove(); $('#svnDirBox .input-group').append(html); $('#svnDirBox #svnDir' + length).chosen(); + $('#svnDirBox #svnDir' + length + '_chosen .chosen-single').css('border-left', '0px'); }) }) diff --git a/module/job/view/create.html.php b/module/job/view/create.html.php index d36b50d71e..2aa21c8149 100644 --- a/module/job/view/create.html.php +++ b/module/job/view/create.html.php @@ -41,7 +41,7 @@ job->svnDir;?> - +
''), '', "class='form-control chosen'");?>
diff --git a/module/job/view/edit.html.php b/module/job/view/edit.html.php index 984e267d04..f414e768d3 100644 --- a/module/job/view/edit.html.php +++ b/module/job/view/edit.html.php @@ -44,12 +44,11 @@ job->svnDir;?> - +
svnDir) { - $job->svnDir = '/zentaoext'; $path = ''; $svnDirs = empty(trim($job->svnDir, '/')) ? '' : $job->svnDir; $svnDirs = explode('/', $svnDirs); diff --git a/module/svn/model.php b/module/svn/model.php index 7e53589ae2..8680dd5891 100644 --- a/module/svn/model.php +++ b/module/svn/model.php @@ -270,40 +270,9 @@ class svnModel extends model */ public function getRepoTags($repo, $path) { - $parent = '/'; - if($repo->prefix) $parent = rtrim($repo->prefix, '/'); - if(trim($path, '/')) $parent = rtrim($repo->prefix, '/') . '/' . trim($path, '/'); - $stmt = $this->dao->select('t1.*,t2.revision as svnRevision,t2.time')->from(TABLE_REPOFILES)->alias('t1') - ->leftJoin(TABLE_REPOHISTORY)->alias('t2')->on('t1.revision = t2.id') - ->where('t1.repo')->eq($repo->id) - ->andWhere('t1.type')->eq('dir') - ->andWhere('t1.parent')->eq($parent) - ->orderBy('path,svnRevision,time') - ->query(); - - $dirs = array(); - while($row = $stmt->fetch()) - { - $path = $row->path; - if($repo->prefix) $path = str_replace($repo->prefix, '', $path); - if(empty($path)) $path = '/'; - - $dirs[$path] = $row; - if($row->action == 'D') unset($dirs[$path]); - } - - $dirTime = array(); - foreach($dirs as $dirPath => $dir) $dirTime[$dir->time][$dirPath] = $dirPath; - - ksort($dirTime); - $dirPairs = array(); - foreach($dirTime as $time => $dirPaths) - { - ksort($dirPaths); - foreach($dirPaths as $dirPath) $dirPairs[$dirPath] = basename($dirPath); - } - - return $dirPairs; + $scm = $this->app->loadClass('scm'); + $scm->setEngine($repo); + return $scm->tags($path); } /**