From 2b4fbf2355a0fad4768486b7e2bffcc0413de6b1 Mon Sep 17 00:00:00 2001 From: aaron <462826@qq.com> Date: Fri, 13 Dec 2019 14:32:24 +0800 Subject: [PATCH] git support --- module/ci/control.php | 21 +++++++++- module/ci/js/browsebranch.js | 4 ++ module/ci/js/browserepo.js | 4 ++ module/ci/js/createrepo.js | 4 ++ module/ci/js/editrepo.js | 4 ++ module/ci/lang/zh-cn.php | 3 ++ module/ci/model.php | 33 ++++++++-------- module/ci/view/browseBranch.html.php | 58 ++++++++++++++++++++++++++++ module/ci/view/browserepo.html.php | 2 +- module/ci/view/header.html.php | 7 +++- module/common/lang/zh-cn.php | 2 +- 11 files changed, 121 insertions(+), 21 deletions(-) create mode 100644 module/ci/js/browsebranch.js create mode 100644 module/ci/js/browserepo.js create mode 100644 module/ci/js/createrepo.js create mode 100644 module/ci/js/editrepo.js create mode 100644 module/ci/view/browseBranch.html.php diff --git a/module/ci/control.php b/module/ci/control.php index 8ca97cdaa6..c627aa5889 100644 --- a/module/ci/control.php +++ b/module/ci/control.php @@ -352,6 +352,25 @@ class ci extends control $this->send(array('result' => 'success')); } + /** + * browse branches. + * + * @param int $repoID + * @access public + * @return void + */ + public function browseBranch($repoID = 0) + { + $repo = $this->ci->getRepoByID($repoID); + $branches = $this->ci->getBranches($repo); + + $this->view->repo = $repo; + $this->view->branches = $branches; + + $this->view->module = 'repo'; + $this->display(); + } + /** * Show sync comment. * @@ -366,7 +385,7 @@ class ci extends control $this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->showSyncComment; $this->view->position[] = $this->lang->repo->showSyncComment; - $latestInDB = $this->ci->getLatestComment($repoID); + $latestInDB = $this->ci->getLatestComment($repoID, ); $this->view->version = $latestInDB ? (int)$latestInDB->commit : 1; $this->view->repoID = $repoID; $this->display(); diff --git a/module/ci/js/browsebranch.js b/module/ci/js/browsebranch.js new file mode 100644 index 0000000000..6126dd22b2 --- /dev/null +++ b/module/ci/js/browsebranch.js @@ -0,0 +1,4 @@ +$(function() +{ + $('#' + module + 'Tab').addClass('btn-active-text'); +}) \ No newline at end of file diff --git a/module/ci/js/browserepo.js b/module/ci/js/browserepo.js new file mode 100644 index 0000000000..6126dd22b2 --- /dev/null +++ b/module/ci/js/browserepo.js @@ -0,0 +1,4 @@ +$(function() +{ + $('#' + module + 'Tab').addClass('btn-active-text'); +}) \ No newline at end of file diff --git a/module/ci/js/createrepo.js b/module/ci/js/createrepo.js new file mode 100644 index 0000000000..6126dd22b2 --- /dev/null +++ b/module/ci/js/createrepo.js @@ -0,0 +1,4 @@ +$(function() +{ + $('#' + module + 'Tab').addClass('btn-active-text'); +}) \ No newline at end of file diff --git a/module/ci/js/editrepo.js b/module/ci/js/editrepo.js new file mode 100644 index 0000000000..420e3dd30d --- /dev/null +++ b/module/ci/js/editrepo.js @@ -0,0 +1,4 @@ +$(function() +{ + $('#' + module + 'Tab').addClass('btn-active-text'); +}); \ No newline at end of file diff --git a/module/ci/lang/zh-cn.php b/module/ci/lang/zh-cn.php index 59007634d3..d925dd8716 100644 --- a/module/ci/lang/zh-cn.php +++ b/module/ci/lang/zh-cn.php @@ -2,6 +2,8 @@ $lang->ci->common = '持续集成'; $lang->ci->list = '列表'; $lang->ci->create = '添加'; +$lang->ci->numb = '序号'; +$lang->ci->name = '名称'; $lang->ci->subModules['credential'] = '凭证'; $lang->ci->subModules['jenkins'] = 'Jenkins'; @@ -75,6 +77,7 @@ $lang->repo->example->encoding = "填写版本库中文件的编码"; $lang->repo->svnCredentialLimt = "Subversion版本库的凭证必须为用户名密码类型"; $lang->repo->showSyncComment = '显示同步进度'; +$lang->repo->watch = '监听'; $lang->repo->notice = new stdclass(); $lang->repo->notice->syncing = '正在同步中, 请稍等...'; diff --git a/module/ci/model.php b/module/ci/model.php index a91fd957e1..2db3349bc0 100644 --- a/module/ci/model.php +++ b/module/ci/model.php @@ -295,6 +295,20 @@ class ciModel extends model return true; } + /** + * Get git branches. + * + * @param object $repo + * @access public + * @return array + */ + public function getBranches($repo) + { + $this->scm = $this->app->loadClass('scm'); + $this->scm->setEngine($repo); + return $this->scm->branch(); + } + /** * Check repo connection * @@ -397,18 +411,18 @@ class ciModel extends model * @access public * @return object */ - public function getLatestComment($repoID) + public function getLatestComment($repoID, $branchID='') { $count = $this->dao->select('count(DISTINCT t1.id) as count')->from(TABLE_REPOHISTORY)->alias('t1') ->leftJoin(TABLE_REPOBRANCH)->alias('t2')->on('t1.id=t2.revision') ->where('t1.repo')->eq($repoID) -// ->beginIF($this->cookie->repoBranch)->andWhere('t2.branch')->eq($this->cookie->repoBranch)->fi() + ->beginIF($branchID)->andWhere('t2.branch')->eq($branchID)->fi() ->fetch('count'); $lastComment = $this->dao->select('t1.*')->from(TABLE_REPOHISTORY)->alias('t1') ->leftJoin(TABLE_REPOBRANCH)->alias('t2')->on('t1.id=t2.revision') ->where('t1.repo')->eq($repoID) -// ->beginIF($this->cookie->repoBranch)->andWhere('t2.branch')->eq($this->cookie->repoBranch)->fi() + ->beginIF($branchID)->andWhere('t2.branch')->eq($branchID)->fi() ->orderBy('t1.time desc') ->limit(1) ->fetch(); @@ -424,19 +438,6 @@ class ciModel extends model return $lastComment; } - /** - * Set repo branch. - * - * @param string $branch - * @access public - * @return void - */ -// public function setRepoBranch($branch) -// { -// setcookie("repoBranch", $branch, 0, $this->config->webRoot); -// $_COOKIE['repoBranch'] = $branch; -// } - /** * Save commit. * diff --git a/module/ci/view/browseBranch.html.php b/module/ci/view/browseBranch.html.php new file mode 100644 index 0000000000..6e3f556bd8 --- /dev/null +++ b/module/ci/view/browseBranch.html.php @@ -0,0 +1,58 @@ + + * @package ci + * @version $Id$ + * @link http://www.zentao.net + */ +?> + + +