Merge branch 'liyuchun_57658'

This commit is contained in:
孙广明
2022-06-23 09:14:54 +08:00
3 changed files with 84 additions and 32 deletions
+29 -20
View File
@@ -356,10 +356,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));
@@ -386,15 +387,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);
@@ -478,21 +484,24 @@ 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->repoGroup = $this->repoGroup;
$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->repoGroup = $this->repoGroup;
$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();
}
+8
View File
@@ -3,6 +3,7 @@
#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: '';}
.pull-left li > a.selected {color: #e9f2fb; background-color: #16a8f8;}
.pull-left li > a {line-height: 20px; border-radius: 5px;}
@@ -13,6 +14,13 @@
#repoList .hide-in-search .hidden {display: block !important; visibility: inherit !important;}
#repoList > ul > li > ul > li > a:hover {color: white; background-color: #0c64eb; text-decoration: none;}
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;}
+47 -12
View File
@@ -14,19 +14,54 @@
<div class='btn-group' id="swapper">
<?php echo $this->repo->getReposMenu($repo, $objectID);?>
</div>
<?php if(!empty($branches)):?>
<?php if(!empty($branchesAndTags)):?>
<div class='btn-group'>
<a href='javascript:;' class='btn btn-link btn-limit text-ellipsis' data-toggle='dropdown' style="max-width: 120px;"><span class='text' title='<?php echo $branches[$branchID];?>'><?php echo $branches[$branchID];?></span> <span class='caret'></span></a>
<ul class='dropdown-menu' style='max-height:240px; max-width: 300px; overflow-y:auto'>
<?php
foreach($branches as $id => $branchName)
{
$isSelected = $id == $branchID ? 'class="selected"' : '';
$base64BranchID = helper::safe64Encode(base64_encode($id));
echo "<li $isSelected>" . html::a($this->createLink('repo', 'browse', "repoID=$repoID&branchID=$base64BranchID&objectID=$objectID"), $branchName, '', "title='{$branchName}' class='text-ellipsis' data-app='{$app->tab}'") . "</li>";
}
?>
</ul>
<a href='javascript:;' class='btn btn-link btn-limit text-ellipsis' data-toggle='dropdown' style="max-width: 120px;"><span class='text' title='<?php echo $branchesAndTags[$branchID];?>'><?php echo $branchesAndTags[$branchID];?></span> <span class='caret'></span></a>
<div id='dropMenuBranch' class='dropdown-menu search-list' data-ride='searchList' data-url=''>
<div class="input-control search-box has-icon-left has-icon-right search-example">
<input type="search" class="form-control search-input" id="searchSource"/>
<label class="input-control-icon-left search-icon"><i class="icon icon-search"></i></label>
<a class="input-control-icon-right search-clear-btn"><i class="icon icon-close icon-sm"></i></a>
</div>
<div class="table-row">
<div class="table-col col-left">
<div class="list-group" id="branchList">
<ul class="tree tree-angles" data-ride="tree" data-idx="0">
<li data-idx='branch' data-id='branch' class='has-list open in' style='cursor: pointer;'>
<i class='list-toggle icon'></i>
<div class='hide-in-search'><a class='text-muted' title='<?php echo $lang->repo->branch;?>'><?php echo $lang->repo->branch;?></a></div>
<ul data-idx='branch'>
<?php
foreach($branches as $branchName)
{
$selected = ($branchName == $branchID and $branchOrTag == 'branch') ? 'selected' : '';
$base64BranchID = helper::safe64Encode(base64_encode($branchName));
$branchLink = $this->createLink('repo', 'browse', "repoID=$repoID&branchID=$base64BranchID&objectID=$objectID");
echo "<li data-idx='$branchName' data-id='branch-$branchName'><a href='$branchLink' id='branch-$branchName' class='$selected branch-or-tag text-ellipsis' title='$branchName' data-key='$branchName'>$branchName</a></li>";
}
?>
</ul>
</li>
<li data-idx='tag' data-id='tag' class='has-list open in' style='cursor: pointer;'>
<i class='list-toggle icon'></i>
<div class='hide-in-search'><a class='text-muted' title='<?php echo $lang->repo->tag;?>'><?php echo $lang->repo->tag;?></a></div>
<ul data-idx='tag'>
<?php
foreach($tags as $tagName)
{
$selected = ($tagName == $branchID and $branchOrTag == 'tag') ? 'selected' : '';
$base64TagID = helper::safe64Encode(base64_encode($tagName));
$tagLink = $this->createLink('repo', 'browse', "repoID=$repoID&branchID=$base64TagID&objectID=$objectID&path=&revision=HEAD&refresh=0&branchOrTag=tag");
echo "<li data-idx='$tagName' data-id='tag-$tagName'><a href='$tagLink' id='tag-$tagName' class='$selected branch-or-tag text-ellipsis' title='$tagName' data-key='$tagName'>$tagName</a></li>";
}
?>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<?php endif;?>
<div class="page-title">