* Adjust svn dir load speed.
This commit is contained in:
@@ -75,14 +75,17 @@ class Subversion
|
||||
foreach($listObject as $list)
|
||||
{
|
||||
$info = new stdclass();
|
||||
$info->size = 0;
|
||||
$info->name = (string)$list->name;
|
||||
$info->path = $resourcePath . '/' . $list->name;
|
||||
$info->kind = (string)$list['kind'];
|
||||
$info->revision = (int)$list->commit['revision'];
|
||||
$info->account = (string)$list->commit->author;
|
||||
$info->date = date('Y-m-d H:i:s', strtotime($list->commit->date));
|
||||
$info->size = $info->kind == 'file' ? (int)$list->size > 1024 ? round((int)$list->size / 1024, 2) . "KB" : (int)$list->size . 'Bytes' : 0;
|
||||
$info->comment = '';
|
||||
$infos[] = $info;
|
||||
|
||||
if($info->kind == 'file') $info->size = (int)$list->size > 1024 ? round((int)$list->size / 1024, 2) . "KB" : (int)$list->size . 'Bytes';
|
||||
$infos[] = $info;
|
||||
}
|
||||
|
||||
/* Sort by kind */
|
||||
|
||||
+26
-17
@@ -320,26 +320,31 @@ class repo extends control
|
||||
$this->commonAction($repoID, $objectID);
|
||||
|
||||
$file = $entry;
|
||||
$repo = $this->repo->getByID($repoID);
|
||||
$entry = $this->repo->decodePath($entry);
|
||||
$entry = urldecode($entry);
|
||||
$pathInfo = helper::mbPathinfo($entry);
|
||||
|
||||
$repo = $this->repo->getByID($repoID);
|
||||
if($repo->SCM == 'Gitlab') $repo = $this->repo->processGitService($repo, true);
|
||||
|
||||
$dropMenus = array();
|
||||
if(in_array($repo->SCM, $this->config->repo->gitTypeList)) $dropMenus = $this->repoZen->getBranchAndTagItems($repo, $this->cookie->repoBranch);
|
||||
|
||||
if($this->app->tab == 'execution') $this->view->executionID = $objectID;
|
||||
$this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->view;
|
||||
$this->view->dropMenus = $this->repoZen->getBranchAndTagItems($repo, $this->cookie->repoBranch);
|
||||
$this->view->type = 'view';
|
||||
$this->view->branchID = $this->cookie->repoBranch;
|
||||
$this->view->showBug = $showBug;
|
||||
$this->view->encoding = $encoding;
|
||||
$this->view->repoID = $repoID;
|
||||
$this->view->objectID = $objectID;
|
||||
$this->view->repo = $repo;
|
||||
$this->view->revision = $revision;
|
||||
$this->view->file = $file;
|
||||
$this->view->entry = $entry;
|
||||
$this->view->pathInfo = $pathInfo;
|
||||
$this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->view;
|
||||
$this->view->dropMenus = $dropMenus;
|
||||
$this->view->type = 'view';
|
||||
$this->view->branchID = $this->cookie->repoBranch;
|
||||
$this->view->showBug = $showBug;
|
||||
$this->view->encoding = $encoding;
|
||||
$this->view->repoID = $repoID;
|
||||
$this->view->objectID = $objectID;
|
||||
$this->view->repo = $repo;
|
||||
$this->view->revision = $revision;
|
||||
$this->view->file = $file;
|
||||
$this->view->entry = $entry;
|
||||
$this->view->pathInfo = $pathInfo;
|
||||
$this->view->tree = $this->repoZen->getViewTree($repo, '', $revision);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -1566,7 +1571,9 @@ class repo extends control
|
||||
{
|
||||
$repo = $this->repo->getByID($repoID);
|
||||
if($path) $path = helper::safe64Decode($path);
|
||||
echo json_encode($this->repo->getGitlabFilesByPath($repo, $path, $branch));
|
||||
|
||||
if($repo->SCM == 'gitlab') return print(json_encode($this->repo->getGitlabFilesByPath($repo, $path, $branch)));
|
||||
return print(json_encode($this->repoZen->getViewTree($repo, $path, $branch)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1578,7 +1585,9 @@ class repo extends control
|
||||
*/
|
||||
public function ajaxGetFileCommitInfo()
|
||||
{
|
||||
$repo = $this->repo->getByID((int)$this->post->repoID);
|
||||
echo json_encode($this->loadModel('gitlab')->getFileLastCommit($repo, $this->post->path, $this->post->branch));
|
||||
$repo = $this->repo->getByID((int)$this->post->repoID);
|
||||
$commit = $this->loadModel('gitlab')->getFileLastCommit($repo, $this->post->path, $this->post->branch);
|
||||
$commit->comment = $this->repo->replaceCommentLink($commit->message);
|
||||
echo json_encode($commit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ window.afterRender = function()
|
||||
// 合并行数据和提交信息
|
||||
oldData[nextCommitRowIndex].date = commit.authoredDate;
|
||||
oldData[nextCommitRowIndex].account = commit.author ? commit.author.username : commit.authorName;
|
||||
oldData[nextCommitRowIndex].comment = commit.message;
|
||||
oldData[nextCommitRowIndex].comment = commit.comment;
|
||||
oldData[nextCommitRowIndex].revision = commit.sha;
|
||||
|
||||
// 重新渲染表格
|
||||
|
||||
@@ -20,15 +20,6 @@ dropmenu
|
||||
set::url(createLink($module, 'ajaxGetDropMenu', "objectID=$objectID&module={$app->rawModule}&method={$app->rawMethod}"))
|
||||
);
|
||||
|
||||
if($repo->SCM == 'Gitlab')
|
||||
{
|
||||
$tree = $this->repo->getGitlabFilesByPath($repo, '', (string)$branchID);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tree = $this->repo->getFileTree($repo);
|
||||
}
|
||||
|
||||
jsVar('isonlybody', isonlybody());
|
||||
jsVar('entry', $entry);
|
||||
jsVar('repoID', $repoID);
|
||||
|
||||
+49
-3
@@ -610,7 +610,6 @@ class repoZen extends repo
|
||||
if($repo->SCM == 'Gitlab')
|
||||
{
|
||||
$_COOKIE['repoBranch'] = $branchID ? $branchID : $this->cookie->repoBranch;
|
||||
|
||||
$infos = $this->repo->getGitlabFilesByPath($repo, $path, $branchID);
|
||||
foreach($infos as &$file)
|
||||
{
|
||||
@@ -625,19 +624,33 @@ class repoZen extends repo
|
||||
$infos = $this->repo->getFileCommits($repo, $branchID, $path);
|
||||
}
|
||||
|
||||
$filePath = $path;
|
||||
if($repo->SCM == 'Subversion')
|
||||
{
|
||||
$scm = $this->app->loadClass('scm');
|
||||
$scm->setEngine($repo);
|
||||
$info = $scm->info('');
|
||||
if(!empty($info->root))
|
||||
{
|
||||
$prefixPath = str_replace($info->root . '/', '', $repo->path);
|
||||
$filePath = trim(str_replace($prefixPath, '', $path), '/');
|
||||
}
|
||||
}
|
||||
|
||||
foreach($infos as $info)
|
||||
{
|
||||
$info->originalComment = $info->comment;
|
||||
$info->comment = $this->repo->replaceCommentLink($info->comment);
|
||||
$info->revision = $repo->SCM == 'Subversion' ? $info->revision : substr($info->revision, 0, 10);
|
||||
if($repo->SCM != 'Subversion') $info->revision = substr($info->revision, 0, 10);
|
||||
|
||||
$infoPath = trim(urldecode($path) . '/' . $info->name, '/');
|
||||
$infoPath = trim(urldecode($path) . '/' . $info->name, '/');
|
||||
if($info->kind == 'dir')
|
||||
{
|
||||
$info->link = $this->repo->createLink('browse', "repoID={$repo->id}&branchID=$base64BranchID&objectID=$objectID&path=" . $this->repo->encodePath($infoPath));
|
||||
}
|
||||
else
|
||||
{
|
||||
if($repo->SCM == 'Subversion') $infoPath = $filePath . '/' . $info->name;
|
||||
$info->link = $this->repo->createLink('view', "repoID={$repo->id}&objectID=$objectID&entry=" . $this->repo->encodePath($infoPath));
|
||||
}
|
||||
}
|
||||
@@ -1465,4 +1478,37 @@ class repoZen extends repo
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详情页面目录树。
|
||||
* Get view tree.
|
||||
*
|
||||
* @param object $repo
|
||||
* @param string $entry
|
||||
* @param string $revision
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function getViewTree(object $repo, string $entry, string $revision): array
|
||||
{
|
||||
if($repo->SCM == 'Gitlab') return $this->repo->getGitlabFilesByPath($repo, '', (string)$this->cookie->repoBranch);
|
||||
|
||||
if($repo->SCM != 'Subversion') return $this->repo->getFileTree($repo);
|
||||
|
||||
$scm = $this->app->loadClass('scm');
|
||||
$scm->setEngine($repo);
|
||||
$tree = $scm->ls($entry, (string)$revision);
|
||||
foreach($tree as &$file)
|
||||
{
|
||||
$base64Name = base64_encode($file->path);
|
||||
|
||||
$file->path = trim($file->path, '/');
|
||||
if(!isset($file->id)) $file->id = $base64Name;
|
||||
if(!isset($file->key)) $file->key = $base64Name;
|
||||
if(!isset($file->text)) $file->text = trim($file->name, '/');
|
||||
if($file->kind == 'dir') $file->items = array('url' => helper::createLink('repo', 'ajaxGetFiles', "repoID={$repo->id}&branch={$revision}&path=" . helper::safe64Encode($file->path)));
|
||||
}
|
||||
|
||||
return $tree;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user