* Finish task #44796.

This commit is contained in:
liyuchun
2021-11-25 14:51:11 +08:00
parent fd3a7312dc
commit e80d9acf37
3 changed files with 14 additions and 6 deletions

View File

@@ -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));
}

View File

@@ -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');

View File

@@ -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;
}
/**