From c96440058c742c42e8e8e07e23def81057ccce85 Mon Sep 17 00:00:00 2001 From: zhaixiaojian Date: Sun, 18 Aug 2024 17:51:49 +0800 Subject: [PATCH] + [task#125055,done,0.5h,0h] Add ajaxGetBranchOptions method. --- module/repo/control.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/module/repo/control.php b/module/repo/control.php index fd6d610584..54c069c7ec 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -1973,4 +1973,25 @@ class repo extends control $this->display(); } + /** + * 通过ajax获取代码库的分支。 + * Ajax: Get branches. + * + * @param int $repoID + * @access public + * @return void + */ + public function ajaxGetBranchOptions(int $repoID) + { + $repo = $this->repo->getByID($repoID); + $scm = $this->app->loadClass('scm'); + $scm->setEngine($repo); + + $options = $this->getBranchAndTagOptions($this->scm); + if(!empty($options[0]['items'])) + { + return print(json_encode($options[0]['items'])); + } + return print(json_encode(array())); + } }