From 4c6ac43ca27d2bc046b74de3b32aea32a63c1ef9 Mon Sep 17 00:00:00 2001 From: liyuchun <563917701@qq.com> Date: Wed, 22 Jun 2022 07:16:38 +0000 Subject: [PATCH] * Finish task #57658. --- module/repo/control.php | 47 +++++++++++++++---------- module/repo/css/browse.css | 8 +++++ module/repo/view/browse.html.php | 59 +++++++++++++++++++++++++------- 3 files changed, 83 insertions(+), 31 deletions(-) diff --git a/module/repo/control.php b/module/repo/control.php index 7d4b2512aa..31ddce9b97 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -355,10 +355,11 @@ class repo extends control * @param string $path * @param string $revision * @param int $refresh + * @param string $branchOrTag branch|tag * @access public * @return void */ - public function browse($repoID = 0, $branchID = '', $objectID = 0, $path = '', $revision = 'HEAD', $refresh = 0) + public function browse($repoID = 0, $branchID = '', $objectID = 0, $path = '', $revision = 'HEAD', $refresh = 0, $branchOrTag = 'branch') { $repoID = $this->repo->saveState($repoID, $objectID); if($branchID) $branchID = base64_decode(helper::safe64Decode($branchID)); @@ -385,15 +386,20 @@ class repo extends control } if(!$repo->synced) $this->locate($this->repo->createLink('showSyncCommit', "repoID=$repoID&objectID=$objectID")); - /* Set branch for git. */ - $branches = array(); + /* Set branch or tag for git. */ + $branches = $tags = $branchesAndTags = array(); if(strpos($repo->SCM, 'Git') !== false) { - $branches = $this->repo->getBranches($repo); + $scm = $this->app->loadClass('scm'); + $scm->setEngine($repo); + $branches = $scm->branch(); + $initTags = $scm->tags(''); + foreach($initTags as $tag) $tags[$tag] = $tag; + $branchesAndTags = $branches + $tags; if(empty($branchID) and $this->cookie->repoBranch and $this->session->repoID == $repoID) $branchID = $this->cookie->repoBranch; if($branchID) $this->repo->setRepoBranch($branchID); - if(!isset($branches[$branchID])) + if(!isset($branchesAndTags[$branchID])) { $branchID = key($branches); $this->repo->setRepoBranch($branchID); @@ -477,20 +483,23 @@ class repo extends control /* Synchronous commit only in root path. */ if(strpos($repo->SCM, 'Git') !== false and empty($path) and $infos and empty($revisions)) $this->locate($this->repo->createLink('showSyncCommit', "repoID=$repoID&objectID=$objectID&branch=" . base64_encode($this->cookie->repoBranch))); - $this->view->title = $this->lang->repo->common; - $this->view->repo = $repo; - $this->view->repos = $this->repos; - $this->view->revisions = $revisions; - $this->view->revision = $revision; - $this->view->infos = $infos; - $this->view->repoID = $repoID; - $this->view->branches = $branches; - $this->view->branchID = $branchID; - $this->view->objectID = $objectID; - $this->view->pager = $pager; - $this->view->path = urldecode($path); - $this->view->logType = $logType; - $this->view->cacheTime = date('m-d H:i', filemtime($cacheFile)); + $this->view->title = $this->lang->repo->common; + $this->view->repo = $repo; + $this->view->repos = $this->repos; + $this->view->revisions = $revisions; + $this->view->revision = $revision; + $this->view->infos = $infos; + $this->view->repoID = $repoID; + $this->view->branches = $branches; + $this->view->tags = $tags; + $this->view->branchesAndTags = $branchesAndTags; + $this->view->branchID = $branchID; + $this->view->objectID = $objectID; + $this->view->pager = $pager; + $this->view->path = urldecode($path); + $this->view->logType = $logType; + $this->view->cacheTime = date('m-d H:i', filemtime($cacheFile)); + $this->view->branchOrTag = $branchOrTag; $this->display(); } diff --git a/module/repo/css/browse.css b/module/repo/css/browse.css index 5a718bb0b5..5d77ae3d66 100644 --- a/module/repo/css/browse.css +++ b/module/repo/css/browse.css @@ -3,8 +3,16 @@ #sidebar>.sidebar-toggle>.icon {right: -2px; left: auto;} .main-row {width: 99%;} .btn-toolbar > .last-sync-time {display: inline-block; float: left; margin-right: 10px;} +.btn-toolbar .page-title {line-height: 28px;} .dropdown-menu > li.selected > a:after {content: '';} +li>a.selected {color: #e9f2fb; background-color: #16a8f8;} +#branchList {line-height: 25px;} +#branchList .hide-in-search, #branchList .tree ul {padding-left: 20px;} +.tree li.has-list.open:before {border-left: none;} +.tree li {padding: 0;} +.branch-or-tag {border-radius: 4px;} + .c-name {min-width: 150px;} .c-checkbox {width: 40px;} .c-version {width: 80px;} diff --git a/module/repo/view/browse.html.php b/module/repo/view/browse.html.php index cfbd61f832..c03d3d6dcf 100644 --- a/module/repo/view/browse.html.php +++ b/module/repo/view/browse.html.php @@ -23,19 +23,54 @@ ?> - +
- - + +