From aa3085e485769d819d3e44e5ec9867b21655c106 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 1 Apr 2021 17:52:38 +0800 Subject: [PATCH] * adjust for repo. --- framework/router.class.php | 2 +- lib/scm/gitrepo.class.php | 126 +++++++++++++++---------------- module/repo/control.php | 8 +- module/repo/view/blame.html.php | 16 ++-- module/repo/view/browse.html.php | 22 +++++- module/repo/view/diff.html.php | 10 +-- module/repo/view/log.html.php | 10 +-- module/repo/view/view.html.php | 16 ++-- 8 files changed, 114 insertions(+), 96 deletions(-) diff --git a/framework/router.class.php b/framework/router.class.php index 36d4fce41e..e665fb722d 100755 --- a/framework/router.class.php +++ b/framework/router.class.php @@ -259,7 +259,7 @@ class router extends baseRouter /* Set default story concept and init UR and SR concept. */ $lang->URCommon = isset($URPairs[$config->URSR]) ? $URPairs[$config->URSR] : reset($URPairs); - $lang->SRCommon = isset($SRPairs[$config->URSR]) ? $URPairs[$config->URSR] : reset($SRPairs); + $lang->SRCommon = isset($SRPairs[$config->URSR]) ? $SRPairs[$config->URSR] : reset($SRPairs); } } diff --git a/lib/scm/gitrepo.class.php b/lib/scm/gitrepo.class.php index 85dc840167..550ae4e754 100644 --- a/lib/scm/gitrepo.class.php +++ b/lib/scm/gitrepo.class.php @@ -5,13 +5,13 @@ class GitRepo public $root; /** - * Construct - * - * @param string $client - * @param string $root - * @param string $username - * @param string $password - * @param string $encoding + * Construct + * + * @param string $client + * @param string $root + * @param string $username + * @param string $password + * @param string $encoding * @access public * @return void */ @@ -29,9 +29,9 @@ class GitRepo /** * List files. - * - * @param string $path - * @param string $revision + * + * @param string $path + * @param string $revision * @access public * @return array */ @@ -40,7 +40,7 @@ class GitRepo if(!scm::checkRevision($revision)) return array(); $path = ltrim($path, DIRECTORY_SEPARATOR); - $sub = ''; + $sub = ''; chdir($this->root); if(!empty($path)) $sub = ":$path"; if(!empty($this->branch))$revision = $this->branch; @@ -69,7 +69,7 @@ class GitRepo } else { - $size .= 'Bytes'; + $size .= 'Bytes'; } $info = new stdClass(); @@ -92,10 +92,10 @@ class GitRepo } /** - * Get tags - * - * @param string $path - * @param string $revision + * Get tags + * + * @param string $path + * @param string $revision * @access public * @return array */ @@ -111,8 +111,8 @@ class GitRepo } /** - * Get branch - * + * Get branch + * * @access public * @return array */ @@ -139,10 +139,10 @@ class GitRepo } /** - * Get last log. - * - * @param string $path - * @param int $count + * Get last log. + * + * @param string $path + * @param int $count * @access public * @return array */ @@ -160,11 +160,11 @@ class GitRepo /** * Get logs - * - * @param string $path - * @param string $fromRevision - * @param string $toRevision - * @param int $count + * + * @param string $path + * @param string $fromRevision + * @param string $toRevision + * @param int $count * @access public * @return array */ @@ -194,7 +194,7 @@ class GitRepo } else { - $revisions = "$fromRevision..$toRevision"; + $revisions = "$fromRevision..$toRevision"; } chdir($this->root); $list = execCmd(escapeCmd("$this->client log --stat=1024 --name-status --stat-name-width=1000 $count $revisions -- $path"), 'array'); @@ -205,9 +205,9 @@ class GitRepo /** * Blame file - * - * @param string $path - * @param string $revision + * + * @param string $path + * @param string $revision * @access public * @return array */ @@ -257,10 +257,10 @@ class GitRepo /** * Diff file. - * - * @param string $path - * @param string $fromRevision - * @param string $toRevision + * + * @param string $path + * @param string $fromRevision + * @param string $toRevision * @access public * @return array */ @@ -284,9 +284,9 @@ class GitRepo /** * Cat file. - * - * @param string $entry - * @param string $revision + * + * @param string $entry + * @param string $revision * @access public * @return string */ @@ -304,9 +304,9 @@ class GitRepo /** * Get info. - * - * @param string $entry - * @param string $revision + * + * @param string $entry + * @param string $revision * @access public * @return object */ @@ -337,17 +337,17 @@ class GitRepo $list = execCmd(escapeCmd("$this->client log -1 $revision --pretty=format:%H -- $path"), 'array'); $revision = $list[0]; $info = new stdclass(); - $info->kind = $kind; - $info->path = $entry; - $info->revision = $revision; - $info->root = $this->root; + $info->kind = $kind; + $info->path = $entry; + $info->revision = $revision; + $info->root = $this->root; return $info; } /** * Exec git cmd. - * - * @param string $cmd + * + * @param string $cmd * @access public * @return array */ @@ -359,8 +359,8 @@ class GitRepo /** * Parse diff. - * - * @param array $lines + * + * @param array $lines * @access public * @return array */ @@ -454,9 +454,9 @@ class GitRepo /** * Get commit count. - * - * @param int $commits - * @param string $lastVersion + * + * @param int $commits + * @param string $lastVersion * @access public * @return int */ @@ -471,7 +471,7 @@ class GitRepo /** * Get first revision. - * + * * @access public * @return string */ @@ -483,8 +483,8 @@ class GitRepo } /** - * Get latest revision - * + * Get latest revision + * * @access public * @return string */ @@ -498,10 +498,10 @@ class GitRepo /** * Get commits. - * - * @param string $version - * @param int $count - * @param string $branch + * + * @param string $version + * @param int $count + * @param string $branch * @access public * @return array */ @@ -543,7 +543,7 @@ class GitRepo { list($account, $date, $hash, $comment) = $parsedCommit; } - else + else { $file = explode(' ', $commit); $file = end($file); @@ -561,8 +561,8 @@ class GitRepo /** * Parse log. - * - * @param array $logs + * + * @param array $logs * @access public * @return array */ @@ -596,7 +596,7 @@ class GitRepo elseif(strpos($line, 'Date:') === 0) { $date = trim(preg_replace('/^Date:/', '', $line)); - $log->time = date('Y-m-d H:i:s', strtotime($date)); + $log->time = date('Y-m-d H:i:s', strtotime($date)); } elseif(preg_match('/^\s{2,}/', $line)) { diff --git a/module/repo/control.php b/module/repo/control.php index 8899210cd7..28fd5cc29a 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -413,10 +413,12 @@ class repo extends control } if($this->cookie->repoRefresh) setcookie('repoRefresh', 0, 0, $this->config->webRoot); - /* Set logType and revisions and synchronous commit. */ + /* Set logType and revisions. */ $logType = 'dir'; $revisions = $this->repo->getCommits($repo, $path, $revision, $logType, $pager); - if($repo->SCM == 'Git' and $infos and empty($revisions)) $this->locate($this->repo->createLink('showSyncCommit', "repoID=$repoID&branch=" . base64_encode($this->cookie->repoBranch))); + + /* Synchronous commit only in root path. */ + if($repo->SCM == 'Git' and empty($path) and $infos and empty($revisions)) $this->locate($this->repo->createLink('showSyncCommit', "repoID=$repoID&objectID=$objectID&branch=" . base64_encode($this->cookie->repoBranch))); /* Set committers. */ $commiters = $this->loadModel('user')->getCommiters(); @@ -490,6 +492,7 @@ class repo extends control $this->view->revision = $revision; $this->view->repoID = $repoID; $this->view->objectID = $objectID; + $this->view->branchID = $this->cookie->repoBranch; $this->view->entry = urldecode($entry); $this->view->path = urldecode($entry); $this->view->file = urldecode($file); @@ -949,7 +952,6 @@ class repo extends control if($repo->SCM != 'Git') die('finish'); if($branch) $branch = base64_decode($branch); - $this->commonAction($repoID); $this->scm->setEngine($repo); $this->repo->setRepoBranch($branch); diff --git a/module/repo/view/blame.html.php b/module/repo/view/blame.html.php index a50010d993..83846cf49b 100644 --- a/module/repo/view/blame.html.php +++ b/module/repo/view/blame.html.php @@ -3,12 +3,12 @@ * The create view file of repo module of ZenTaoPMS. * * @copyright Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com) - * @author Wang Yidong, Zhu Jinyong + * @author Wang Yidong, Zhu Jinyong * @package repo * @version $Id: blame.html.php $ */ ?> - repo->createLink('browse', "repoID=$repoID&branchID=$branchID&objectID=$objectID"), $repo->name); + echo html::a($this->repo->createLink('browse', "repoID=$repoID&branchID=$branchID&objectID=$objectID"), $repo->name, '', "data-app='{$app->openApp}"); $paths= explode('/', $entry); $fileName = array_pop($paths); $postPath = ''; foreach($paths as $pathName) { $postPath .= $pathName . '/'; - echo '/' . ' ' . html::a($this->repo->createLink('browse', "repoID=$repoID&branchID=$branchID&objectID=$objectID&path=" . $this->repo->encodePath($postPath)), trim($pathName, '/')); + echo '/' . ' ' . html::a($this->repo->createLink('browse', "repoID=$repoID&branchID=$branchID&objectID=$objectID&path=" . $this->repo->encodePath($postPath)), trim($pathName, '/'), '', "data-app='{$app->openApp}'"); } echo '/' . ' ' . $fileName; echo " " . $revisionName . ''; @@ -58,7 +58,7 @@ css::import($jsRoot . 'misc/highlight/styles/github.css'); repo->encodingList, $encoding, $lang->repo->encoding) . "", "id='encoding' data-toggle='dropdown'", 'btn dropdown-toggle')?> @@ -80,7 +80,7 @@ css::import($jsRoot . 'misc/highlight/styles/github.css'); > - SCM == 'Git' ? substr($blame['revision'], 0, 10) : $blame['revision']; echo ''; if($repo->SCM == 'Git') echo '' . zget($historys, $blame['revision'], '') . ''; - echo '' . $blame['committer'] . ''; + echo '' . $blame['committer'] . ''; } ?>
- + diff --git a/module/repo/view/browse.html.php b/module/repo/view/browse.html.php index aa405f192f..076cf5cbb7 100644 --- a/module/repo/view/browse.html.php +++ b/module/repo/view/browse.html.php @@ -3,7 +3,7 @@ * The browse view file of repo module of ZenTaoPMS. * * @copyright Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com) - * @author Wang Yidong, Zhu Jinyong + * @author Wang Yidong, Zhu Jinyong * @package repo * @version $Id: browse.html.php $ */ @@ -17,7 +17,7 @@ $repoName) { - echo "
  • " . html::a($this->createLink('repo', 'browse', "repoID=$id"), $repoName, '', "title='{$repoName}' class='text-ellipsis'") . "
  • "; + echo "
  • " . html::a($this->createLink('repo', 'browse', "repoID=$id&branchID=&objectID=$objectID"), $repoName, '', "title='{$repoName}' class='text-ellipsis' data-app='{$app->openApp}'") . "
  • "; } ?> @@ -29,12 +29,28 @@ $branchName) { - echo "
  • " . html::a($this->createLink('repo', 'browse', "repoID=$repoID&branchID=$id"), $branchName, '', "title='{$branchName}' class='text-ellipsis'") . "
  • "; + echo "
  • " . html::a($this->createLink('repo', 'browse', "repoID=$repoID&branchID=$id&objectID=$objectID"), $branchName, '', "title='{$branchName}' class='text-ellipsis' data-app='{$app->openApp}'") . "
  • "; } ?> +
    + + repo->createLink('browse', "repoID=$repoID&branchID=$branchID&objectID=$objectID"), $repo->name, '', "data-app='{$app->openApp}'"); + $paths= explode('/', $path); + $fileName = array_pop($paths); + $postPath = ''; + foreach($paths as $pathName) + { + $postPath .= $pathName . '/'; + echo '/' . ' ' . html::a($this->repo->createLink('browse', "repoID=$repoID&branchID=$branchID&objectID=$objectID&path=" . $this->repo->encodePath($postPath)), trim($pathName, '/'), '', "data-app='{$app->openApp}'"); + } + echo '/' . ' ' . $fileName; + ?> + +
    repo->notice->lastSyncTime . $cacheTime?> diff --git a/module/repo/view/diff.html.php b/module/repo/view/diff.html.php index 3a1934949c..a3bc6c237e 100644 --- a/module/repo/view/diff.html.php +++ b/module/repo/view/diff.html.php @@ -3,7 +3,7 @@ * The diff view file of repo module of ZenTaoPMS. * * @copyright Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com) - * @author Wang Yidong, Zhu Jinyong + * @author Wang Yidong, Zhu Jinyong * @package repo * @version $Id: browse.html.php $ */ @@ -18,7 +18,7 @@ $backURI = $this->session->repoView ? $this->session->repoView : $this->session->repoList; if($backURI) { - echo html::a($backURI, "" . $lang->goback, '', "class='btn btn-link'"); + echo html::a($backURI, "" . $lang->goback, '', "class='btn btn-link' data-app='{$app->openApp}'"); } else { @@ -28,14 +28,14 @@
    repo->createLink('browse', "repoID=$repoID"), $repo->name); + echo html::a($this->repo->createLink('browse', "repoID=$repoID"), $repo->name, '', "data-app='{$app->openApp}'"); $paths= explode('/', $entry); $fileName = array_pop($paths); $postPath = ''; foreach($paths as $pathName) { $postPath .= $pathName . '/'; - echo '/' . ' ' . html::a($this->repo->createLink('browse', "repoID=$repoID&branchID=$branchID&objectID=$objectID&path=" . $this->repo->encodePath($postPath)), trim($pathName, '/')); + echo '/' . ' ' . html::a($this->repo->createLink('browse', "repoID=$repoID&branchID=$branchID&objectID=$objectID&path=" . $this->repo->encodePath($postPath)), trim($pathName, '/'), '', "data-app='{$app->openApp}'"); } echo '/' . ' ' . $fileName; if($repo->SCM == 'Git') @@ -120,7 +120,7 @@ { $newlc = $line->oldlc; $line->type = 'custom'; - } + } } else { diff --git a/module/repo/view/log.html.php b/module/repo/view/log.html.php index 88625c9024..7b707fd023 100644 --- a/module/repo/view/log.html.php +++ b/module/repo/view/log.html.php @@ -3,7 +3,7 @@ * The log view file of repo module of ZenTaoPMS. * * @copyright Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com) - * @author Wang Yidong, Zhu Jinyong + * @author Wang Yidong, Zhu Jinyong * @package repo * @version $Id: log.html.php $ */ @@ -19,14 +19,14 @@
    repo->createLink('log', "repoID=$repoID"), $repo->name); + echo html::a($this->repo->createLink('log', "repoID=$repoID&objectID=$objectID"), $repo->name, '', "data-app='{$app->openApp}'"); $paths= explode('/', $entry); $fileName = array_pop($paths); $postPath = ''; foreach($paths as $pathName) { $postPath .= $pathName . '/'; - echo '/' . ' ' . html::a($this->repo->createLink('log', "repoID=$repoID&entry=" . $this->repo->encodePath($postPath)), trim($pathName, '/')); + echo '/' . ' ' . html::a($this->repo->createLink('log', "repoID=$repoID&ojbectID=$objectID&entry=" . $this->repo->encodePath($postPath)), trim($pathName, '/'), '', "data-app='{$app->openApp}'"); } echo '/' . ' ' . $fileName; ?> @@ -40,9 +40,9 @@ diff --git a/module/repo/view/view.html.php b/module/repo/view/view.html.php index 5b74847f84..4f6cd0cef7 100644 --- a/module/repo/view/view.html.php +++ b/module/repo/view/view.html.php @@ -3,12 +3,12 @@ * The create view file of repo module of ZenTaoPMS. * * @copyright Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com) - * @author Wang Yidong, Zhu Jinyong + * @author Wang Yidong, Zhu Jinyong * @package repo * @version $Id: create.html.php $ */ ?> -$revisionName";
    repo->createLink('browse', "repoID=$repoID&branchID=$branchID&objectID=$objectID"), $repo->name); + echo html::a($this->repo->createLink('browse', "repoID=$repoID&branchID=$branchID&objectID=$objectID"), $repo->name, '', "data-app='{$app->openApp}'"); $paths= explode('/', $entry); $fileName = array_pop($paths); $postPath = ''; foreach($paths as $pathName) { $postPath .= $pathName . '/'; - echo '/' . ' ' . html::a($this->repo->createLink('browse', "repoID=$repoID&branchID=$branchID&objectID=$objectID&path=" . $this->repo->encodePath($postPath)), trim($pathName, '/')); + echo '/' . ' ' . html::a($this->repo->createLink('browse', "repoID=$repoID&branchID=$branchID&objectID=$objectID&path=" . $this->repo->encodePath($postPath)), trim($pathName, '/'), '', "data-app='{$app->openApp}'"); } echo '/' . ' ' . $fileName; echo $version; @@ -41,7 +41,7 @@ $version = " $revisionName";
    - repo->createLink('revision', "repoID=$repoID&objectID=$objectID&revision=$revision"), $lang->repo->allChanges, '', "class='btn btn-primary'")?> + repo->createLink('revision', "repoID=$repoID&objectID=$objectID&revision=$revision"), $lang->repo->allChanges, '', "class='btn btn-primary' data-app='{$app->openApp}'")?>
    @@ -55,7 +55,7 @@ $version = " $revisionName";
    repo->images, "|$suffix|") === false):?> - repo->createLink('blame', "repoID=$repoID&objectID=$objectID&entry=$encodePath&revision=$revision&encoding=$encoding"), html::icon('random') . $lang->repo->blame, '', "class='btn btn-sm btn-primary' data-app='{$app->openApp}'"); if(common::hasPriv('repo', 'download')) echo html::a($this->repo->createLink('download', "repoID=$repoID&path=$encodePath&fromRevision=$revision"), html::icon('download-alt') . $lang->repo->download, 'hiddenwin', "class='btn btn-sm btn-primary'"); ?> @@ -91,8 +91,8 @@ $version = " $revisionName";